🎨 Centralize error throwing for encryption keys and credentials (#3105)
* Centralized error throwing for encryption key * Unifying the error message used by cli and core packages * Improvements to error messages to make it more DRY * Removed unnecessary throw * Throwing error when credential does not exist to simplify node behavior (#3112) Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
@@ -24,10 +24,6 @@ import {
|
||||
export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query?: IDataObject): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = await this.getCredentials('trelloApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
query = query || {};
|
||||
|
||||
query.key = credentials.apiKey;
|
||||
|
||||
@@ -70,10 +70,6 @@ export class TrelloTrigger implements INodeType {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
const credentials = await this.getCredentials('trelloApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
// Check all the webhooks which exist already if it is identical to the
|
||||
// one that is supposed to get created.
|
||||
const endpoint = `tokens/${credentials.apiToken}/webhooks`;
|
||||
@@ -98,9 +94,6 @@ export class TrelloTrigger implements INodeType {
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
|
||||
const credentials = await this.getCredentials('trelloApi');
|
||||
if (credentials === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const idModel = this.getNodeParameter('id') as string;
|
||||
|
||||
@@ -129,9 +122,6 @@ export class TrelloTrigger implements INodeType {
|
||||
|
||||
if (webhookData.webhookId !== undefined) {
|
||||
const credentials = await this.getCredentials('trelloApi');
|
||||
if (credentials === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
const endpoint = `tokens/${credentials.apiToken}/webhooks/${webhookData.webhookId}`;
|
||||
|
||||
@@ -171,10 +161,6 @@ export class TrelloTrigger implements INodeType {
|
||||
|
||||
const credentials = await this.getCredentials('trelloApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
// TODO: Check why that does not work as expected even though it gets done as described
|
||||
// https://developers.trello.com/page/webhooks
|
||||
// // Check if the request is valid
|
||||
|
||||
Reference in New Issue
Block a user