mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 17:14:05 -08:00
071130a2dc
Co-authored-by: oleg <oleg@n8n.io>
26 lines
609 B
TypeScript
26 lines
609 B
TypeScript
export interface ErrorLike {
|
|
message?: string;
|
|
description?: string;
|
|
}
|
|
|
|
export interface ErrorContext {
|
|
modelName?: string;
|
|
}
|
|
|
|
export function makeErrorFromStatus(statusCode: number, context?: ErrorContext): ErrorLike {
|
|
const errorMessages: Record<number, ErrorLike> = {
|
|
403: {
|
|
message: 'Unauthorized for this project',
|
|
description:
|
|
'Check your Google Cloud project ID, and that your credential has access to that project',
|
|
},
|
|
404: {
|
|
message: context?.modelName
|
|
? `No model found called '${context.modelName}'`
|
|
: 'No model found',
|
|
},
|
|
};
|
|
|
|
return errorMessages[statusCode];
|
|
}
|