Skip to content

Commit

Permalink
Fix: Unwrap nested errors in error handler for Crystal::Error (#12888)
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota authored Jan 4, 2023
1 parent 59b77bc commit 939772e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/compiler/crystal/command.cr
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ class Crystal::Command
rescue ex : Crystal::Error
report_warnings

# This unwraps nested errors which could be caused by `require` which wraps
# errors in order to trace the require path. The causes are listed similarly
# to `#inspect_with_backtrace` but without the backtrace.
while cause = ex.cause
error ex.message, exit_code: nil
ex = cause
end

error ex.message
rescue ex : OptionParser::Exception
error ex.message
Expand Down

0 comments on commit 939772e

Please sign in to comment.