Exception: PowerTrack::WithStatusPowerTrackError
- Inherits:
-
BasePowerTrackError
- Object
- StandardError
- BasePowerTrackError
- PowerTrack::WithStatusPowerTrackError
- Defined in:
- lib/powertrack/errors.rb
Overview
Base class for PowerTrack errors with a precise status
Direct Known Subclasses
InvalidResponseError, PredefinedStatusPowerTrackError, UnknownStatusError
Instance Attribute Summary
Attributes inherited from BasePowerTrackError
Class Method Summary collapse
-
.build(status, message, body) ⇒ Object
Factory method which returns an error instance based on a given status.
Methods inherited from BasePowerTrackError
Constructor Details
This class inherits a constructor from PowerTrack::BasePowerTrackError
Class Method Details
.build(status, message, body) ⇒ Object
Factory method which returns an error instance based on a given status.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/powertrack/errors.rb', line 35 def self.build(status, , body) @@status_to_error_class ||= Hash[*self.descendants.map { |desc| [ desc.new(nil, nil).status, desc ] }.flatten ] if @@status_to_error_class.key?(status) @@status_to_error_class[status].new(, body) else # default to unknown status error UnknownStatusError.new(status, , body) end end |