@integration-app/sdk
Advanced tools
Comparing version 0.1.54 to 0.1.55
@@ -56,2 +56,3 @@ export declare enum ErrorType { | ||
declare class EngineErrorOptions { | ||
type?: ErrorType; | ||
key?: string; | ||
@@ -82,2 +83,4 @@ helpText?: string; | ||
export declare class EngineError extends Error { | ||
isIntegrationAppError: true; | ||
type: ErrorType; | ||
key: string; | ||
@@ -90,2 +93,3 @@ helpText?: string; | ||
export declare class InternalError extends EngineError { | ||
constructor(message: any, options?: EngineErrorOptions); | ||
} | ||
@@ -123,3 +127,3 @@ export declare class BadRequestError extends EngineError { | ||
export declare function getErrorFromData(data: any): InternalError | BadRequestError | FlowRunError | EndpointError | ConnectionError; | ||
export declare function extractEngineErrorData(error: Error): InternalErrorData | EndpointErrorData | ConnectionErrorData | FlowConfigurationErrorData | FlowRunErrorData | BadRequestErrorData; | ||
export declare function extractEngineErrorData(error: any): InternalErrorData | EndpointErrorData | ConnectionErrorData | FlowConfigurationErrorData | FlowRunErrorData | BadRequestErrorData; | ||
export {}; |
166
errors.js
@@ -112,3 +112,6 @@ "use strict"; | ||
constructor(message, options = {}) { | ||
var _a; | ||
super(message); | ||
this.type = (_a = options.type) !== null && _a !== void 0 ? _a : ErrorType.INTERNAL; | ||
this.isIntegrationAppError = true; | ||
this.key = options.key; | ||
@@ -122,2 +125,8 @@ this.helpText = options.helpText; | ||
class InternalError extends EngineError { | ||
constructor(message, options = {}) { | ||
super(message, { | ||
...options, | ||
type: ErrorType.INTERNAL, | ||
}); | ||
} | ||
} | ||
@@ -127,3 +136,6 @@ exports.InternalError = InternalError; | ||
constructor(message, options = {}) { | ||
super(message, options); | ||
super(message, { | ||
...options, | ||
type: ErrorType.BAD_REQUEST, | ||
}); | ||
this.fields = options.fields; | ||
@@ -135,3 +147,6 @@ } | ||
constructor(message, options = {}) { | ||
super(message, options); | ||
super(message, { | ||
...options, | ||
type: ErrorType.FLOW_CONFIGURATION, | ||
}); | ||
this.flowId = options.flowId; | ||
@@ -144,3 +159,6 @@ this.nodeId = options.nodeId; | ||
constructor(message, options = {}) { | ||
super(message, options); | ||
super(message, { | ||
...options, | ||
type: ErrorType.FLOW_RUN, | ||
}); | ||
this.flowRunId = options.flowRunId; | ||
@@ -154,3 +172,6 @@ this.flowNodeRunId = options.flowNodeRunId; | ||
constructor(message, options = {}) { | ||
super(message, options); | ||
super(message, { | ||
...options, | ||
type: ErrorType.ENDPOINT, | ||
}); | ||
this.endpointKey = options.endpointKey; | ||
@@ -162,3 +183,6 @@ } | ||
constructor(message, options = {}) { | ||
super(message, options); | ||
super(message, { | ||
...options, | ||
type: ErrorType.CONNECTION, | ||
}); | ||
this.connectionKey = options.connectionKey; | ||
@@ -210,71 +234,71 @@ this.connectionId = options.connectionId; | ||
function extractEngineErrorData(error) { | ||
if (error instanceof FlowConfigurationError) { | ||
return new FlowConfigurationErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
flowId: error.flowId, | ||
nodeId: error.nodeId, | ||
}); | ||
if (error.isIntegrationAppError) { | ||
if (error.type == ErrorType.FLOW_CONFIGURATION) { | ||
return new FlowConfigurationErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
flowId: error.flowId, | ||
nodeId: error.nodeId, | ||
}); | ||
} | ||
else if (error.type == ErrorType.FLOW_CONFIGURATION) { | ||
return new FlowRunErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
flowRunId: error.flowRunId, | ||
flowNodeRunId: error.flowNodeRunId, | ||
nodeKey: error.nodeKey, | ||
}); | ||
} | ||
else if (error.type == ErrorType.ENDPOINT) { | ||
return new EndpointErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
endpointKey: error.endpointKey, | ||
}); | ||
} | ||
else if (error.type == ErrorType.CONNECTION) { | ||
return new ConnectionErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
connectionKey: error.connectionKey, | ||
}); | ||
} | ||
else if (error.type == ErrorType.BAD_REQUEST) { | ||
return new BadRequestErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
fields: error.fields, | ||
}); | ||
} | ||
else if (error.type == ErrorType.INTERNAL) { | ||
return new InternalErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpTest: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
}); | ||
} | ||
} | ||
else if (error instanceof FlowRunError) { | ||
return new FlowRunErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
flowRunId: error.flowRunId, | ||
flowNodeRunId: error.flowNodeRunId, | ||
nodeKey: error.nodeKey, | ||
}); | ||
} | ||
else if (error instanceof EndpointError) { | ||
return new EndpointErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
endpointKey: error.endpointKey, | ||
}); | ||
} | ||
else if (error instanceof ConnectionError) { | ||
return new ConnectionErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
connectionKey: error.connectionKey, | ||
}); | ||
} | ||
else if (error instanceof BadRequestError) { | ||
return new BadRequestErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
fields: error.fields, | ||
}); | ||
} | ||
else if (error instanceof InternalError) { | ||
return new InternalErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpTest: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
}); | ||
} | ||
else { | ||
return new InternalErrorData({ | ||
message: `Unknown error: ${error.message}`, | ||
}); | ||
} | ||
return new InternalErrorData({ | ||
message: `Unknown error: ${error.message}`, | ||
}); | ||
} | ||
exports.extractEngineErrorData = extractEngineErrorData; | ||
//# sourceMappingURL=errors.js.map |
{ | ||
"name": "@integration-app/sdk", | ||
"version": "0.1.54", | ||
"version": "0.1.55", | ||
"description": "JavaScript SDK for Integration.app", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -121,2 +121,3 @@ import _ from 'lodash' | ||
class EngineErrorOptions { | ||
public type?: ErrorType | ||
public key?: string | ||
@@ -153,2 +154,4 @@ public helpText?: string | ||
export class EngineError extends Error { | ||
public isIntegrationAppError: true | ||
public type: ErrorType | ||
public key: string | ||
@@ -161,2 +164,4 @@ public helpText?: string | ||
super(message) | ||
this.type = options.type ?? ErrorType.INTERNAL | ||
this.isIntegrationAppError = true | ||
this.key = options.key | ||
@@ -169,3 +174,10 @@ this.helpText = options.helpText | ||
export class InternalError extends EngineError {} | ||
export class InternalError extends EngineError { | ||
constructor(message, options: EngineErrorOptions = {}) { | ||
super(message, { | ||
...options, | ||
type: ErrorType.INTERNAL, | ||
}) | ||
} | ||
} | ||
@@ -176,3 +188,6 @@ export class BadRequestError extends EngineError { | ||
constructor(message, options: BadRequestErrorOptions = {}) { | ||
super(message, options) | ||
super(message, { | ||
...options, | ||
type: ErrorType.BAD_REQUEST, | ||
}) | ||
this.fields = options.fields | ||
@@ -187,3 +202,6 @@ } | ||
constructor(message, options: FlowConfigurationErrorOptions = {}) { | ||
super(message, options) | ||
super(message, { | ||
...options, | ||
type: ErrorType.FLOW_CONFIGURATION, | ||
}) | ||
this.flowId = options.flowId | ||
@@ -200,3 +218,6 @@ this.nodeId = options.nodeId | ||
constructor(message, options: FlowRunErrorOptions = {}) { | ||
super(message, options) | ||
super(message, { | ||
...options, | ||
type: ErrorType.FLOW_RUN, | ||
}) | ||
this.flowRunId = options.flowRunId | ||
@@ -212,3 +233,6 @@ this.flowNodeRunId = options.flowNodeRunId | ||
constructor(message, options: EndpointErrorOptions = {}) { | ||
super(message, options) | ||
super(message, { | ||
...options, | ||
type: ErrorType.ENDPOINT, | ||
}) | ||
this.endpointKey = options.endpointKey | ||
@@ -223,3 +247,6 @@ } | ||
constructor(message, options: ConnectionErrorOptions = {}) { | ||
super(message, options) | ||
super(message, { | ||
...options, | ||
type: ErrorType.CONNECTION, | ||
}) | ||
this.connectionKey = options.connectionKey | ||
@@ -264,64 +291,65 @@ this.connectionId = options.connectionId | ||
export function extractEngineErrorData(error: Error) { | ||
if (error instanceof FlowConfigurationError) { | ||
return new FlowConfigurationErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
flowId: error.flowId, | ||
nodeId: error.nodeId, | ||
}) | ||
} else if (error instanceof FlowRunError) { | ||
return new FlowRunErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
flowRunId: error.flowRunId, | ||
flowNodeRunId: error.flowNodeRunId, | ||
nodeKey: error.nodeKey, | ||
}) | ||
} else if (error instanceof EndpointError) { | ||
return new EndpointErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
endpointKey: error.endpointKey, | ||
}) | ||
} else if (error instanceof ConnectionError) { | ||
return new ConnectionErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
connectionKey: error.connectionKey, | ||
}) | ||
} else if (error instanceof BadRequestError) { | ||
return new BadRequestErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
fields: error.fields, | ||
}) | ||
} else if (error instanceof InternalError) { | ||
return new InternalErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpTest: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
}) | ||
} else { | ||
return new InternalErrorData({ | ||
message: `Unknown error: ${error.message}`, | ||
}) | ||
export function extractEngineErrorData(error: any) { | ||
if (error.isIntegrationAppError) { | ||
if (error.type == ErrorType.FLOW_CONFIGURATION) { | ||
return new FlowConfigurationErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
flowId: error.flowId, | ||
nodeId: error.nodeId, | ||
}) | ||
} else if (error.type == ErrorType.FLOW_CONFIGURATION) { | ||
return new FlowRunErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
flowRunId: error.flowRunId, | ||
flowNodeRunId: error.flowNodeRunId, | ||
nodeKey: error.nodeKey, | ||
}) | ||
} else if (error.type == ErrorType.ENDPOINT) { | ||
return new EndpointErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
endpointKey: error.endpointKey, | ||
}) | ||
} else if (error.type == ErrorType.CONNECTION) { | ||
return new ConnectionErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
connectionKey: error.connectionKey, | ||
}) | ||
} else if (error.type == ErrorType.BAD_REQUEST) { | ||
return new BadRequestErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpText: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
fields: error.fields, | ||
}) | ||
} else if (error.type == ErrorType.INTERNAL) { | ||
return new InternalErrorData({ | ||
message: error.message, | ||
key: error.key, | ||
helpTest: error.helpText, | ||
helpLink: error.helpLink, | ||
causedByError: error.causedByError, | ||
}) | ||
} | ||
} | ||
return new InternalErrorData({ | ||
message: `Unknown error: ${error.message}`, | ||
}) | ||
} |
Sorry, the diff of this file is not supported yet
990786
11863