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:
कारतोफ्फेलस्क्रिप्ट™
2022-11-22 14:00:36 +01:00
committed by GitHub
parent 5364e7fc92
commit 0b754a4f85
29 changed files with 253 additions and 393 deletions

View File

@@ -152,7 +152,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.ResponseError(errorMessage, 500, 500);
throw new ResponseHelper.InternalServerError(errorMessage);
}
const additionalKeys: IWorkflowDataProxyAdditionalKeys = {
@@ -169,7 +169,7 @@ export async function executeWebhook(
try {
user = await getWorkflowOwner(workflowData.id.toString());
} catch (error) {
throw new ResponseHelper.ResponseError('Cannot find workflow', undefined, 404);
throw new ResponseHelper.NotFoundError('Cannot find workflow');
}
}
@@ -212,7 +212,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.ResponseError(errorMessage, 500, 500);
throw new ResponseHelper.InternalServerError(errorMessage);
}
// Add the Response and Request so that this data can be accessed in the node
@@ -661,7 +661,7 @@ export async function executeWebhook(
responseCallback(new Error('There was a problem executing the workflow'), {});
}
throw new ResponseHelper.ResponseError(e.message, 500, 500);
throw new ResponseHelper.InternalServerError(e.message);
});
// eslint-disable-next-line consistent-return
@@ -671,7 +671,7 @@ export async function executeWebhook(
responseCallback(new Error('There was a problem executing the workflow'), {});
}
throw new ResponseHelper.ResponseError(e.message, 500, 500);
throw new ResponseHelper.InternalServerError(e.message);
}
}