| 4723 | #define JS_DUMP_ERROR_MAX_CAUSE_DEPTH 10 |
| 4724 | |
| 4725 | static void js_std_dump_error1(JSContext *ctx, JSValueConst exception_val) |
| 4726 | { |
| 4727 | JSValue val, current; |
| 4728 | bool is_error; |
| 4729 | int depth; |
| 4730 | |
| 4731 | current = JS_DupValue(ctx, exception_val); |
| 4732 | for (depth = 0; ; depth++) { |
| 4733 | is_error = JS_IsError(current); |
| 4734 | js_dump_obj(ctx, stderr, current); |
| 4735 | if (is_error) { |
| 4736 | val = JS_GetPropertyStr(ctx, current, "stack"); |
| 4737 | } else if (depth == 0) { |
| 4738 | js_std_cmd(/*ErrorBackTrace*/2, ctx, &val); |
| 4739 | } else { |
| 4740 | val = JS_UNDEFINED; |
| 4741 | } |
| 4742 | if (!JS_IsUndefined(val)) { |
| 4743 | js_dump_obj(ctx, stderr, val); |
| 4744 | JS_FreeValue(ctx, val); |
| 4745 | } |
| 4746 | if (!is_error || depth >= JS_DUMP_ERROR_MAX_CAUSE_DEPTH) |
| 4747 | break; |
| 4748 | val = JS_GetPropertyStr(ctx, current, "cause"); |
| 4749 | if (JS_IsUndefined(val)) { |
| 4750 | JS_FreeValue(ctx, val); |
| 4751 | break; |
| 4752 | } |
| 4753 | fputs("Caused by: ", stderr); |
| 4754 | JS_FreeValue(ctx, current); |
| 4755 | current = val; |
| 4756 | } |
| 4757 | JS_FreeValue(ctx, current); |
| 4758 | } |
| 4759 | |
| 4760 | void js_std_dump_error(JSContext *ctx) |
| 4761 | { |
no test coverage detected