refactor(core): Enable useUnknownInCatchVariables in workflow package (no-changelog) (#7549)

This commit is contained in:
Iván Ovejero 2023-10-31 13:59:33 +01:00 committed by GitHub
parent b350568505
commit c6b688387c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 10 deletions

View file

@ -35,7 +35,9 @@ import type {
INodePropertyCollection, INodePropertyCollection,
NodeParameterValueType, NodeParameterValueType,
PostReceiveAction, PostReceiveAction,
JsonObject,
} from './Interfaces'; } from './Interfaces';
import type { NodeError } from './NodeErrors';
import { NodeApiError, NodeOperationError } from './NodeErrors'; import { NodeApiError, NodeOperationError } from './NodeErrors';
import * as NodeHelpers from './NodeHelpers'; import * as NodeHelpers from './NodeHelpers';
@ -211,16 +213,29 @@ export class RoutingNode {
returnData.push(...responseData); returnData.push(...responseData);
} catch (error) { } catch (error) {
if (thisArgs !== undefined && thisArgs.continueOnFail()) { if (thisArgs !== undefined && thisArgs.continueOnFail()) {
returnData.push({ json: {}, error: error.message }); returnData.push({ json: {}, error: error as NodeError });
continue; continue;
} }
if (error instanceof NodeApiError) error = error.cause;
throw new NodeApiError(this.node, error, { interface AxiosError extends NodeError {
isAxiosError: boolean;
description: string | undefined;
response?: { status: number };
}
let routingError = error as AxiosError;
if (error instanceof NodeApiError) routingError = error.cause as AxiosError;
throw new NodeApiError(this.node, error as JsonObject, {
runIndex, runIndex,
itemIndex: i, itemIndex: i,
message: error?.message, message: routingError?.message,
description: error?.description, description: routingError?.description,
httpCode: error.isAxiosError && error.response && String(error.response?.status), httpCode:
routingError.isAxiosError && routingError.response
? String(routingError.response?.status)
: 'none',
}); });
} }
} }
@ -276,7 +291,7 @@ export class RoutingNode {
}); });
}); });
} catch (error) { } catch (error) {
throw new NodeOperationError(this.node, error, { throw new NodeOperationError(this.node, error as Error, {
runIndex, runIndex,
itemIndex, itemIndex,
description: `The rootProperty "${action.properties.property}" could not be found on item.`, description: `The rootProperty "${action.properties.property}" could not be found on item.`,

View file

@ -7,9 +7,7 @@
"paths": { "paths": {
"@/*": ["./*"] "@/*": ["./*"]
}, },
"tsBuildInfoFile": "dist/typecheck.tsbuildinfo", "tsBuildInfoFile": "dist/typecheck.tsbuildinfo"
// TODO: remove all options below this line
"useUnknownInCatchVariables": false
}, },
"include": ["src/**/*.ts", "test/**/*.ts"] "include": ["src/**/*.ts", "test/**/*.ts"]
} }