lib/berkshelf/errors.rb in berkshelf-2.0.3 vs lib/berkshelf/errors.rb in berkshelf-2.0.4
- old
+ new
@@ -121,23 +121,30 @@
class ConstraintNotSatisfied < BerkshelfError; status_code(111); end
class InvalidChefAPILocation < BerkshelfError; status_code(112); end
class BerksfileReadError < BerkshelfError
# @param [#status_code] original_error
def initialize(original_error)
- @original_error = original_error
+ @original_error = original_error
+ @error_message = original_error.to_s
+ @error_backtrace = original_error.backtrace
end
status_code(113)
def status_code
@original_error.respond_to?(:status_code) ? @original_error.status_code : 113
end
+ alias_method :original_backtrace, :backtrace
+ def backtrace
+ Array(@error_backtrace) + Array(original_backtrace)
+ end
+
def to_s
[
"An error occurred while reading the Berksfile:",
"",
- " " + @original_error.to_s.split("\n").map(&:strip).join("\n "),
+ " #{@error_message}",
].join("\n")
end
end
class MismatchedCookbookName < BerkshelfError