n8n/packages/@n8n/nodes-langchain/nodes/llms/LmChatGoogleVertex/error-handling.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
609 B
TypeScript
Raw Normal View History

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];
}