Module: ErrorExtractor::ClassMethods
- Defined in:
- lib/error_extractor.rb
Instance Method Summary collapse
Instance Method Details
#extract_errors(e) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/error_extractor.rb', line 18 def extract_errors(e) if e.respond_to?(:record) && __present?(e.record) && __present?(e.record&.errors&.&.to_sentence) e.record.errors..to_sentence elsif e.respond_to?(:message) e. elsif e.respond_to?(:to_s) e.to_s else e end end |
#extract_errors_with_backtrace(e) ⇒ Object
30 31 32 33 |
# File 'lib/error_extractor.rb', line 30 def extract_errors_with_backtrace(e) "#{extract_errors(e)}\n" + "#{e.respond_to?(:backtrace) ? e.backtrace.join("\n") : ""}" end |