Include 400 in policy error status codes
Browse filesAdded HTTP 400 (Bad Request) to the list of status codes considered as policy errors in isPolicyError. This broadens the error handling to treat client-side validation issues as policy errors.
src/lib/server/router/endpoint.ts
CHANGED
|
@@ -76,8 +76,8 @@ function extractUpstreamError(error: unknown): { message: string; statusCode?: n
|
|
| 76 |
*/
|
| 77 |
function isPolicyError(statusCode?: number): boolean {
|
| 78 |
if (!statusCode) return false;
|
| 79 |
-
// 402: Payment Required, 401: Unauthorized, 403: Forbidden
|
| 80 |
-
return statusCode ===
|
| 81 |
}
|
| 82 |
|
| 83 |
function stripReasoningBlocks(text: string): string {
|
|
|
|
| 76 |
*/
|
| 77 |
function isPolicyError(statusCode?: number): boolean {
|
| 78 |
if (!statusCode) return false;
|
| 79 |
+
// 400: Bad Request, 402: Payment Required, 401: Unauthorized, 403: Forbidden
|
| 80 |
+
return statusCode === 400 || statusCode === 401 || statusCode === 402 || statusCode === 403;
|
| 81 |
}
|
| 82 |
|
| 83 |
function stripReasoningBlocks(text: string): string {
|