Last active
October 17, 2018 14:04
-
-
Save kristopherjohnson/e650487a5dc0ce9dd24ea2584db63e18 to your computer and use it in GitHub Desktop.
Ruby: Pretty-printed exception backtrace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate a backtrace string for given exception. | |
# Generated string is a series of lines, each beginning with a tab and "at ". | |
def pretty_backtrace(exception) | |
"\tat #{exception.backtrace.join("\n\tat ")}" | |
end | |
# Generate a string containing exception message followed by backtrace. | |
def pretty_exception(exception) | |
"#{exception.message}\n#{pretty_backtrace(exception)}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example uses: