From 62a92c3f5ee3eb01c4b10b84dcbaddbd200a1154 Mon Sep 17 00:00:00 2001 From: neimadTL Date: Thu, 13 Feb 2025 09:32:33 -0400 Subject: [PATCH] Update custom errors with Exception#full_message The use of `Exception#full_message` makes more sense as it shows the cause and the backstrace. --- bundler/lib/bundler/errors.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bundler/lib/bundler/errors.rb b/bundler/lib/bundler/errors.rb index 8cd133635607..d8df4d6ec5c5 100644 --- a/bundler/lib/bundler/errors.rb +++ b/bundler/lib/bundler/errors.rb @@ -131,7 +131,8 @@ class GemRequireError < BundlerError attr_reader :orig_exception def initialize(orig_exception, msg) - full_message = msg + "\nGem Load Error is: #{orig_exception.message}\n"\ + full_message = msg + "\nGem Load Error is: + #{orig_exception.full_message(highlight: false)}\n"\ "Backtrace for gem load error is:\n"\ "#{orig_exception.backtrace.join("\n")}\n"\ "Bundler Error Backtrace:\n" @@ -221,7 +222,9 @@ def initialize(underlying_error, message) class DirectoryRemovalError < BundlerError def initialize(orig_exception, msg) full_message = "#{msg}.\n" \ - "The underlying error was #{orig_exception.class}: #{orig_exception.message}, with backtrace:\n" \ + "The underlying error was #{orig_exception.class}: + #{orig_exception.full_message(highlight: false)}, + with backtrace:\n" \ " #{orig_exception.backtrace.join("\n ")}\n\n" \ "Bundler Error Backtrace:" super(full_message)