(obj: any, depth = 0)
| 27 | } |
| 28 | |
| 29 | export function handledStringify(obj: any, depth = 0): string { |
| 30 | try { |
| 31 | if (depth > 0) { |
| 32 | const limitedObj = truncateObject(obj, 0, depth); |
| 33 | return JSON.stringify(limitedObj); |
| 34 | } |
| 35 | |
| 36 | return JSON.stringify(obj); |
| 37 | } catch (error) { |
| 38 | if (error instanceof Error) { |
| 39 | return error.stack || error.message; |
| 40 | } |
| 41 | return 'Unknown error when Stringify'; |
| 42 | } |
| 43 | } |
no test coverage detected