-
Notifications
You must be signed in to change notification settings - Fork 49
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
Get raw stacktrace #16
Comments
How do you setup PE? Is it like |
require("pretty-error").start(); is how i start it. Should i do it the other way instead? |
Well we could (and probably should) provide an api for that. But right now, if you wanna intercept an error before PE modifies it, you could do something like this: PrettyError = require '../lib/pretty-error'
pe = new PrettyError()
prepare = Error.prepareStackTrace or (exc, frames) ->
result = exc.toString()
frames = frames.map (frame) -> " at #{frame.toString()}"
result + "\n" + frames.join "\n"
# We replace the original Error.prepareStackTrace with a custom one
Error.prepareStackTrace = (exc, trace) =>
# Apply the modifications that were originally intended to be
# applied on the stack trace
stack = prepare.apply(null, arguments)
# now we have access to the original stack trace
console.log stack
# and we can render the trace too
pe.render {stack, message: exc.toString().replace /^.*: /, ''}, no
# Just a sample error to test things
a = b I could rewrite this in JS if you prefer though. |
Closing this issue since it's been inactive for some time. |
I'm creating a rest api and when in development mode i also return all errors via json as well as logging it to the console. However the prettified stack trace is unreadable when it is returned as a string. Is there a way for me to get the raw stack trace before it was modified?
Example:
The text was updated successfully, but these errors were encountered: