Skip to content

Commit a271351

Browse files
fix(tools): surface HTTP status on error ToolResponse output
executeTool's catch handled Error instances in its first branch and only extracted status/statusText/data for non-Error object throws — so HTTP errors (thrown as Error instances carrying .status) lost their status on the returned output. Surface it for Error instances too, so callers can branch on the status (e.g. the enrichment cascade treating a provider 404 as a no-match).
1 parent 5c6a70b commit a271351

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

apps/sim/tools/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,18 @@ export async function executeTool(
11561156

11571157
if (error instanceof Error) {
11581158
errorMessage = error.message || `Error executing tool ${toolId}`
1159+
// HTTP errors are thrown as Error instances carrying `status`/`statusText`/
1160+
// `data` (see createTransformedErrorFromErrorInfo). Surface them on the
1161+
// output so callers can branch on the status (e.g. treat 404 as a clean
1162+
// no-match) — the object branch below only ran for non-Error throws.
1163+
const httpStatus = (error as { status?: unknown }).status
1164+
if (typeof httpStatus === 'number') {
1165+
errorDetails = {
1166+
status: httpStatus,
1167+
statusText: (error as { statusText?: string }).statusText,
1168+
data: (error as { data?: unknown }).data,
1169+
}
1170+
}
11591171
} else if (typeof error === 'string') {
11601172
errorMessage = error
11611173
} else if (error && typeof error === 'object') {

0 commit comments

Comments
 (0)