Class: Sandals::ErrorDetails

Inherits:
Object
  • Object
show all
Defined in:
lib/sandals/error_details.rb

Constant Summary collapse

ANSI_ESCAPE =
/\e\[[0-9;]*m/

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error, fallback_path:) ⇒ ErrorDetails

Returns a new instance of ErrorDetails.



11
12
13
14
# File 'lib/sandals/error_details.rb', line 11

def initialize(error, fallback_path:)
  @error = error
  @fallback_path = fallback_path
end

Class Method Details

.for(error, fallback_path: nil) ⇒ Object



7
8
9
# File 'lib/sandals/error_details.rb', line 7

def self.for(error, fallback_path: nil)
  new(error, fallback_path:).to_h
end

Instance Method Details

#to_hObject



16
17
18
19
20
21
22
# File 'lib/sandals/error_details.rb', line 16

def to_h
  {
    class: @error.class.to_s,
    message: clean_message,
    location: error_location
  }
end