Skip to content

Commit fd5b1f7

Browse files
committed
fix: handle error messages that are not instanceof Error
1 parent bff5c65 commit fd5b1f7

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/main.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,22 +149,20 @@ function registerTool(tool: ToolDefinition): void {
149149
};
150150
} catch (error) {
151151
logger(`${tool.name} response handling error:`, error, error.stack);
152-
const errorText =
153-
error instanceof Error ? error.message : String(error);
154-
155-
return {
156-
content: [
157-
{
158-
type: 'text',
159-
text: errorText,
160-
},
161-
],
162-
isError: true,
163-
};
152+
throw error;
164153
}
165154
} catch (err) {
166155
logger(`${tool.name} error:`, err, err.stack);
167-
throw err;
156+
const errorText = 'message' in err ? err.message : String(err);
157+
return {
158+
content: [
159+
{
160+
type: 'text',
161+
text: errorText,
162+
},
163+
],
164+
isError: true,
165+
};
168166
} finally {
169167
guard.dispose();
170168
}

0 commit comments

Comments
 (0)