Class: OpenStax::RescueFrom::ExceptionProxy
- Inherits:
-
Object
- Object
- OpenStax::RescueFrom::ExceptionProxy
- Defined in:
- lib/openstax/rescue_from/exception_proxy.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
Instance Method Summary collapse
- #cause ⇒ Object
- #error_id ⇒ Object
- #extras ⇒ Object
- #first_backtrace_line ⇒ Object
- #friendly_message ⇒ Object
-
#initialize(exception) ⇒ ExceptionProxy
constructor
A new instance of ExceptionProxy.
- #logger_backtrace ⇒ Object
- #message ⇒ Object
- #name ⇒ Object
- #sorry ⇒ Object
- #status ⇒ Object
- #status_code ⇒ Object
Constructor Details
#initialize(exception) ⇒ ExceptionProxy
Returns a new instance of ExceptionProxy.
6 7 8 |
# File 'lib/openstax/rescue_from/exception_proxy.rb', line 6 def initialize(exception) @exception = exception end |
Instance Attribute Details
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
4 5 6 |
# File 'lib/openstax/rescue_from/exception_proxy.rb', line 4 def exception @exception end |
Instance Method Details
#cause ⇒ Object
30 31 32 |
# File 'lib/openstax/rescue_from/exception_proxy.rb', line 30 def cause @cause ||= exception.cause if exception.respond_to?(:cause) end |
#error_id ⇒ Object
14 15 16 |
# File 'lib/openstax/rescue_from/exception_proxy.rb', line 14 def error_id @error_id ||= RescueFrom.generate_id end |
#extras ⇒ Object
26 27 28 |
# File 'lib/openstax/rescue_from/exception_proxy.rb', line 26 def extras @extras ||= RescueFrom.extras_proc(name).call(exception) end |
#first_backtrace_line ⇒ Object
38 39 40 |
# File 'lib/openstax/rescue_from/exception_proxy.rb', line 38 def first_backtrace_line @first_backtrace_line ||= exception.backtrace&.first end |
#friendly_message ⇒ Object
22 23 24 |
# File 'lib/openstax/rescue_from/exception_proxy.rb', line 22 def RescueFrom.(self) end |
#logger_backtrace ⇒ Object
34 35 36 |
# File 'lib/openstax/rescue_from/exception_proxy.rb', line 34 def logger_backtrace @backtrace ||= exception.backtrace&.join("\n") end |
#message ⇒ Object
18 19 20 |
# File 'lib/openstax/rescue_from/exception_proxy.rb', line 18 def @message ||= exception. end |
#name ⇒ Object
10 11 12 |
# File 'lib/openstax/rescue_from/exception_proxy.rb', line 10 def name @name ||= exception.class.name end |
#sorry ⇒ Object
50 51 52 53 54 |
# File 'lib/openstax/rescue_from/exception_proxy.rb', line 50 def sorry return @sorry unless @sorry.nil? @sorry = RescueFrom.sorry(name) end |
#status ⇒ Object
42 43 44 |
# File 'lib/openstax/rescue_from/exception_proxy.rb', line 42 def status @status ||= RescueFrom.status(name) end |
#status_code ⇒ Object
46 47 48 |
# File 'lib/openstax/rescue_from/exception_proxy.rb', line 46 def status_code @status_code ||= RescueFrom.http_code(status) end |