ATlast — you'll never need to find your favorites on another platform again. Find your favs in the ATmosphere.
atproto
16
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(api): use 400 for zod validation error not 500

byarielm.fyi e58c4c0e b2be992c

verified
+18
+18
packages/api/src/middleware/error.ts
··· 1 1 import { Context } from "hono"; 2 + import { ZodError } from "zod"; 2 3 import { 3 4 ApiError, 4 5 AuthenticationError, ··· 30 31 { 31 32 success: false, 32 33 error: err.message, 34 + }, 35 + 400, 36 + ); 37 + } 38 + 39 + // Handle Zod validation errors (from schema parsing) 40 + if (err instanceof ZodError) { 41 + const firstIssue = err.issues[0]; 42 + const message = firstIssue 43 + ? `${firstIssue.path.join(".")}: ${firstIssue.message}` 44 + : "Validation failed"; 45 + 46 + return c.json( 47 + { 48 + success: false, 49 + error: message, 50 + details: err.issues, 33 51 }, 34 52 400, 35 53 );