mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
1 parent
d02d8959f6
commit
00d9d4d005
1 file changed
+22
-19
+22
-19
@@ -411,30 +411,33 @@ export class SessionManager {
|
||||
// Convert provider errors to standard OpenAI APIError with appropriate code
|
||||
if (error?.status === 400) {
|
||||
const code = 'bad_request';
|
||||
throw new OpenAI.APIError(
|
||||
{ status: error.status, code, message: `${error.status} Provider returned error` },
|
||||
{ method: 'POST', url: '', body: {}, status: error.status },
|
||||
error.name,
|
||||
error.cause
|
||||
);
|
||||
const apiError = new OpenAI.APIError({
|
||||
status: error.status,
|
||||
code,
|
||||
message: `${error.status} Provider returned error`
|
||||
});
|
||||
apiError.code = code;
|
||||
throw apiError;
|
||||
}
|
||||
if (error?.status === 403) {
|
||||
const code = 'key_limit_exceeded';
|
||||
throw new OpenAI.APIError(
|
||||
{ status: error.status, code, message: `${error.status} Provider returned error` },
|
||||
{ method: 'POST', url: '', body: {}, status: error.status },
|
||||
error.name,
|
||||
error.cause
|
||||
);
|
||||
const apiError = new OpenAI.APIError({
|
||||
status: error.status,
|
||||
code,
|
||||
message: `${error.status} Provider returned error`
|
||||
});
|
||||
apiError.code = code;
|
||||
throw apiError;
|
||||
}
|
||||
if (error?.status === 422) {
|
||||
const code = 'unprocessable_entity';
|
||||
throw new OpenAI.APIError(
|
||||
{ status: error.status, code, message: `${error.status} Provider returned error` },
|
||||
{ method: 'POST', url: '', body: {}, status: error.status },
|
||||
error.name,
|
||||
error.cause
|
||||
);
|
||||
const code = 'unprocessable_entity'
|
||||
const apiError = new OpenAI.APIError({
|
||||
status: error.status,
|
||||
code,
|
||||
message: `${error.status} Provider returned error`
|
||||
});
|
||||
apiError.code = code;
|
||||
throw apiError;
|
||||
}
|
||||
|
||||
// Re-throw service errors to be handled at the UI level
|
||||
|
||||
Reference in new issue
Block a user