mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor: Improve error logging/reporting for cli (#4691)
* use response error classes instead of `ResponseError` everywhere * improve error logging in dev mode or when telemetry is disabled
This commit is contained in:
committed by
GitHub
parent
5364e7fc92
commit
0b754a4f85
@@ -91,7 +91,7 @@ workflowsController.post(
|
||||
|
||||
if (!savedWorkflow) {
|
||||
LoggerProxy.error('Failed to create workflow', { userId: req.user.id });
|
||||
throw new ResponseHelper.ResponseError('Failed to save workflow');
|
||||
throw new ResponseHelper.InternalServerError('Failed to save workflow');
|
||||
}
|
||||
|
||||
if (tagIds && !config.getEnv('workflowTagsDisabled') && savedWorkflow.tags) {
|
||||
@@ -152,13 +152,11 @@ workflowsController.get(
|
||||
`/from-url`,
|
||||
ResponseHelper.send(async (req: express.Request): Promise<IWorkflowResponse> => {
|
||||
if (req.query.url === undefined) {
|
||||
throw new ResponseHelper.ResponseError(`The parameter "url" is missing!`, undefined, 400);
|
||||
throw new ResponseHelper.BadRequestError(`The parameter "url" is missing!`);
|
||||
}
|
||||
if (!/^http[s]?:\/\/.*\.json$/i.exec(req.query.url as string)) {
|
||||
throw new ResponseHelper.ResponseError(
|
||||
throw new ResponseHelper.BadRequestError(
|
||||
`The parameter "url" is not valid! It does not seem to be a URL pointing to a n8n workflow JSON file.`,
|
||||
undefined,
|
||||
400,
|
||||
);
|
||||
}
|
||||
let workflowData: IWorkflowResponse | undefined;
|
||||
@@ -166,11 +164,7 @@ workflowsController.get(
|
||||
const { data } = await axios.get<IWorkflowResponse>(req.query.url as string);
|
||||
workflowData = data;
|
||||
} catch (error) {
|
||||
throw new ResponseHelper.ResponseError(
|
||||
`The URL does not point to valid JSON file!`,
|
||||
undefined,
|
||||
400,
|
||||
);
|
||||
throw new ResponseHelper.BadRequestError(`The URL does not point to valid JSON file!`);
|
||||
}
|
||||
|
||||
// Do a very basic check if it is really a n8n-workflow-json
|
||||
@@ -182,10 +176,8 @@ workflowsController.get(
|
||||
typeof workflowData.connections !== 'object' ||
|
||||
Array.isArray(workflowData.connections)
|
||||
) {
|
||||
throw new ResponseHelper.ResponseError(
|
||||
throw new ResponseHelper.BadRequestError(
|
||||
`The data in the file does not seem to be a n8n workflow JSON file!`,
|
||||
undefined,
|
||||
400,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -222,10 +214,8 @@ workflowsController.get(
|
||||
workflowId,
|
||||
userId: req.user.id,
|
||||
});
|
||||
throw new ResponseHelper.ResponseError(
|
||||
throw new ResponseHelper.NotFoundError(
|
||||
'Could not load the workflow - you can only access workflows owned by you',
|
||||
undefined,
|
||||
404,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -297,10 +287,8 @@ workflowsController.delete(
|
||||
workflowId,
|
||||
userId: req.user.id,
|
||||
});
|
||||
throw new ResponseHelper.ResponseError(
|
||||
throw new ResponseHelper.BadRequestError(
|
||||
'Could not delete the workflow - you can only remove workflows owned by you',
|
||||
undefined,
|
||||
400,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user