Add BAD_REQUEST status code

This commit is contained in:
2026-08-03 03:19:48 +00:00
parent d924ddcbe7
commit c17565ab24
+5 -3
View File
@@ -7,11 +7,13 @@ import { toExtendedJson, fromExtendedJson } from '@xo-cash/utils';
import { z } from 'zod'; import { z } from 'zod';
import type { Logger } from '../../utils/logger.ts'; import type { Logger } from '../../utils/logger.ts';
import { ApplicationError, normalizePublicError } from '../../errors/index.ts';
import type { ApplicationRequest, ApplicationRouter } from '../router.ts'; import type { ApplicationRequest, ApplicationRouter } from '../router.ts';
import { WSStream } from '../stream/ws-stream.ts';
import type { AppEnv, UpgradeTransportRouter } from './transport-router.ts'; import type { AppEnv, UpgradeTransportRouter } from './transport-router.ts';
import { ApplicationError, normalizePublicError } from '../../errors/index.ts';
import { HTTP_STATUS_CODE_BAD_REQUEST } from '../../constants.ts';
import { WSStream } from '../stream/ws-stream.ts';
/** Default WebSocket upgrade path for application messages. */ /** Default WebSocket upgrade path for application messages. */
const WS_ROUTE = '/ws'; const WS_ROUTE = '/ws';
@@ -198,7 +200,7 @@ export class WsTransportRouter implements UpgradeTransportRouter {
try { try {
decoded = fromExtendedJson(payload); decoded = fromExtendedJson(payload);
} catch { } catch {
throw new ApplicationError(400, 'Invalid JSON in WebSocket message'); throw new ApplicationError(HTTP_STATUS_CODE_BAD_REQUEST, 'Invalid JSON in WebSocket message');
} }
const envelope = wsRequestSchema.parse(decoded); const envelope = wsRequestSchema.parse(decoded);