Skip to content

Commit cbbf972

Browse files
committed
fix(tools): use toError in crowdstrike catch block instead of local getErrorMessage
The catch block was calling the local getErrorMessage function which parses CrowdStrike API JSON responses, not JavaScript Error objects. Use toError(error).message to correctly extract the message from a caught value in this context.
1 parent e1864cb commit cbbf972

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • apps/sim/app/api/tools/crowdstrike/query

apps/sim/app/api/tools/crowdstrike/query/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createLogger } from '@sim/logger'
2+
import { toError } from '@sim/utils/errors'
23
import { generateId } from '@sim/utils/id'
34
import { type NextRequest, NextResponse } from 'next/server'
45
import { crowdstrikeQueryContract } from '@/lib/api/contracts/tools/crowdstrike'
@@ -405,7 +406,7 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
405406
output: normalizeAggregatesOutput(aggregateData),
406407
})
407408
} catch (error) {
408-
const message = getErrorMessage(error, 'Unknown error')
409+
const message = toError(error).message
409410
logger.error(`[${requestId}] CrowdStrike request failed`, { error: message })
410411
return NextResponse.json({ success: false, error: message }, { status: 500 })
411412
}

0 commit comments

Comments
 (0)