refactor(core): Reorganize error hierarchy in cli package (no-changelog) (#7839)

Ensure all errors in `cli` inherit from `ApplicationError` to continue
normalizing all the errors we report to Sentry

Follow-up to: https://github.com/n8n-io/n8n/pull/7820
This commit is contained in:
Iván Ovejero
2023-11-28 10:19:27 +01:00
committed by GitHub
parent 38f24a6184
commit 1c6178759c
81 changed files with 346 additions and 297 deletions

View File

@@ -63,6 +63,9 @@ import { OwnershipService } from './services/ownership.service';
import { parseBody } from './middlewares';
import { WorkflowsService } from './workflows/workflows.services';
import { Logger } from './Logger';
import { NotFoundError } from './errors/response-errors/not-found.error';
import { InternalServerError } from './errors/response-errors/internal-server.error';
import { UnprocessableRequestError } from './errors/response-errors/unprocessable.error';
const pipeline = promisify(stream.pipeline);
@@ -237,7 +240,7 @@ export async function executeWebhook(
if (nodeType === undefined) {
const errorMessage = `The type of the webhook node "${workflowStartNode.name}" is not known`;
responseCallback(new Error(errorMessage), {});
throw new ResponseHelper.InternalServerError(errorMessage);
throw new InternalServerError(errorMessage);
}
const additionalKeys: IWorkflowDataProxyAdditionalKeys = {
@@ -254,7 +257,7 @@ export async function executeWebhook(
try {
user = await Container.get(OwnershipService).getWorkflowOwnerCached(workflowData.id);
} catch (error) {
throw new ResponseHelper.NotFoundError('Cannot find workflow');
throw new NotFoundError('Cannot find workflow');
}
}
@@ -294,7 +297,7 @@ export async function executeWebhook(
// that something does not resolve properly.
const errorMessage = `The response mode '${responseMode}' is not valid!`;
responseCallback(new Error(errorMessage), {});
throw new ResponseHelper.InternalServerError(errorMessage);
throw new InternalServerError(errorMessage);
}
// Add the Response and Request so that this data can be accessed in the node
@@ -781,13 +784,13 @@ export async function executeWebhook(
responseCallback(new Error('There was a problem executing the workflow'), {});
}
throw new ResponseHelper.InternalServerError(e.message);
throw new InternalServerError(e.message);
});
}
return executionId;
} catch (e) {
const error =
e instanceof ResponseHelper.UnprocessableRequestError
e instanceof UnprocessableRequestError
? e
: new Error('There was a problem executing the workflow', { cause: e });
if (didSendResponse) throw error;