mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
handle 422s and surface to quilly
This commit is contained in:
1 parent
1a9a553523
commit
185cdc51fb
2 files changed
+20
No files matched your search
@@ -114,6 +114,15 @@ export function Quilly({ error, onDismiss, onNewChat, onOpenModelSelector, onReq
|
||||
},
|
||||
};
|
||||
|
||||
case 'unprocessable_entity':
|
||||
return {
|
||||
message: 'Request rejected by AI provider. Try a different model.',
|
||||
action: {
|
||||
label: 'Choose model',
|
||||
onClick: onOpenModelSelector,
|
||||
},
|
||||
};
|
||||
|
||||
case 'server_error':
|
||||
case 'service_unavailable':
|
||||
return {
|
||||
|
||||
@@ -408,6 +408,17 @@ export class SessionManager {
|
||||
return; // User cancelled
|
||||
}
|
||||
|
||||
// Convert UnprocessableEntityError to standard OpenAI APIError with code
|
||||
if (error?.constructor?.name === 'UnprocessableEntityError') {
|
||||
const apiError = new OpenAI.APIError({
|
||||
status: 422,
|
||||
code: 'unprocessable_entity',
|
||||
message: '422 Provider returned error'
|
||||
});
|
||||
apiError.code = 'unprocessable_entity';
|
||||
throw apiError;
|
||||
}
|
||||
|
||||
// Re-throw service errors to be handled at the UI level
|
||||
throw error;
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user