MCPcopy Index your code
hub / github.com/simstudioai/sim / mapWorkflowGroupError

Function mapWorkflowGroupError

apps/sim/app/api/table/[tableId]/groups/route.ts:32–49  ·  view source on GitHub ↗

* Maps known service-layer error messages onto HTTP responses; falls through * to a 500 with a generic message for anything unrecognized. The three * group-route handlers all surface the same error shapes from * `addWorkflowGroup` / `updateWorkflowGroup` / `deleteWorkflowGroup`, so they * share

(error: unknown, fallbackMessage: string)

Source from the content-addressed store, hash-verified

30 * share this mapper instead of repeating the if-chain three times.
31 */
32function mapWorkflowGroupError(error: unknown, fallbackMessage: string): NextResponse {
33 if (error instanceof Error) {
34 const msg = error.message
35 if (msg === 'Table not found' || msg.includes('not found')) {
36 return NextResponse.json({ error: msg }, { status: 404 })
37 }
38 if (
39 msg.includes('Schema validation') ||
40 msg.includes('Missing column definition') ||
41 msg.includes('already exists') ||
42 msg.includes('exceed')
43 ) {
44 return NextResponse.json({ error: msg }, { status: 400 })
45 }
46 }
47 logger.error(fallbackMessage, error)
48 return NextResponse.json({ error: fallbackMessage }, { status: 500 })
49}
50
51/** POST /api/table/[tableId]/groups — create a workflow group + its output columns. */
52export const POST = withRouteHandler(async (request: NextRequest, { params }: RouteParams) => {

Callers 1

route.tsFile · 0.85

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected