mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 04:30:48 +00:00
fix: handle edge case where JSON.stringify returns undefined
Add fallback to String() when JSON.stringify returns undefined, which can happen with objects that have toJSON() returning undefined.
This commit is contained in:
parent
7fdebe8fe6
commit
4f664d00ac
2 changed files with 12 additions and 1 deletions
|
|
@ -125,6 +125,15 @@ describe('errors', () => {
|
|||
const obj = { message: 123 };
|
||||
expect(getErrorMessage(obj)).toBe('{"message":123}');
|
||||
});
|
||||
|
||||
it('should fallback to String() when toJSON returns undefined', () => {
|
||||
const obj = {
|
||||
toJSON() {
|
||||
return undefined;
|
||||
},
|
||||
};
|
||||
expect(getErrorMessage(obj)).toBe('[object Object]');
|
||||
});
|
||||
});
|
||||
|
||||
describe('handleError', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue