-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rfc] include stack trace when stringifying exception object #630
Comments
I think the challenge here is that everyone likely borrowed the code from libc that prints the stack: Line 4063 in d2bca87
Those would need to be adjusted, which I really don't mind. I'm not sure I understand this part:
Are the 2 sentences related? I guess no, then if we are to special-case exception objects we might as well stringify the stack trace? But at the same time that is somewhat inconsistent with All of that to say I don't think I have a strong opinion 😅 |
They're related in the sense that we ought to call the .toString method but we don't, we take a shortcut to avoid invoking JS code. And since we're doing that for the sake of debuggability, I figured we might as well go the whole way. |
Oh, and a semi-related thing: |
Note that
Checking for I guess the API should have been different, taking the pointer by reference and returning a status that can be checked directly. Changing that seems overkill. Your proposition, including the stack trace in the special that emulates What is your use case ? |
I left a comment (#632 (comment)) in another issue just now that outlines what I'm looking for: an infallible to-string method that's free of side effects (no JS calls) and returns something that's (edit: maximally!) useful to human eyes. I'll close this issue, let's continue the discussion in the other one. |
JS_ToCStringLen2
(and thereforeJS_ToCString
andJS_ToCStringLen
) currently special-cases exception objects:https://github.com/quickjs-ng/quickjs/blob/d2bca87c64e41162e3da0ffe0a19858a81b09db4/quickjs.c#L4091-L4106
That is, it stringifies
obj.message
and returns that. That only tells you what though, not where.I want to include
obj.stack
as well to make debugging easier but I'm wondering if that could break existing code somehow. The most visible change is that the string is going to contain newlines where before it (usually) didn't.The text was updated successfully, but these errors were encountered: