Module: CzechPostB2bClient::B2BErrors

Defined in:
lib/czech_post_b2b_client/b2b_errors.rb

Defined Under Namespace

Classes: BadRequestError, BaseError, CustomerRequestsCountOverflowError, InternalB2BServerError, InternalBackendServerError, InternalDataPersistenceServerError, ProcessingUnfinishedYetError, ServiceBusyError, UnauthorizedContractAccessError, UnauthorizedRoleAccessError

Class Method Summary collapse

Class Method Details

.all_error_classesObject

have t be at end of file, to collect all classes defined before



100
101
102
# File 'lib/czech_post_b2b_client/b2b_errors.rb', line 100

def self.all_error_classes
  ObjectSpace.each_object(CzechPostB2bClient::B2BErrors::BaseError.singleton_class)
end

.new_by_code(code, details = '') ⇒ Object



104
105
106
107
108
109
# File 'lib/czech_post_b2b_client/b2b_errors.rb', line 104

def self.new_by_code(code, details = '')
  klass = all_error_classes.detect { |k| k.code == code }
  raise "B2BError with code: #{code} is unknown!" unless klass

  klass.new(details)
end