-
-
Save ryanbriones/442509 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class WrappedError < StandardError | |
attr_reader :original_error, :message_with_original_error | |
def initialize(original_error = nil) | |
@original_error = original_error | |
end | |
def message | |
@message_with_original_error ||= "" | |
if original_error | |
message_with_original_error << | |
" The original error was:\n\n" << | |
dashed_line_separator << | |
"\t" << original_error_message << | |
original_error_backtrace << | |
"\n" << dashed_line_separator | |
end | |
message_with_original_error | |
end | |
private | |
def dashed_line_separator | |
"-" * 80 << "\n" | |
end | |
def original_error_backtrace | |
original_error.backtrace.join("\n\t\t") | |
end | |
def original_error_message | |
original_error.message + " at:\n\t\t" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment