Exception: PowerTrack::WithStatusPowerTrackError

Inherits:
BasePowerTrackError show all
Defined in:
lib/powertrack/errors.rb

Overview

Base class for PowerTrack errors with a precise status

Instance Attribute Summary

Attributes inherited from BasePowerTrackError

#body, #status

Class Method Summary collapse

Methods inherited from BasePowerTrackError

#initialize

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, message, 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(message, body)
  else
    # default to unknown status error
    UnknownStatusError.new(status, message, body)
  end
end