Module: ShipEngine::Exceptions

Defined in:
lib/shipengine/exceptions.rb

Defined Under Namespace

Classes: RateLimitError, ShipEngineError, SystemError, ValidationError

Class Method Summary collapse

Class Method Details

.invalid_field_value_error(message:) ⇒ Object

only create custom errors for error “types” (which encompass codes). Prefer to use generic ShipEngine errors.



26
27
28
29
30
31
# File 'lib/shipengine/exceptions.rb', line 26

def invalid_field_value_error(message:)
  ValidationError.new(
    message: message,
    code: ShipEngine::Errors::ErrorCode.get(:INVALID_FIELD_VALUE)
  )
end

.required_error(field_name:) ⇒ Object



33
34
35
36
37
38
# File 'lib/shipengine/exceptions.rb', line 33

def required_error(field_name:)
  ValidationError.new(
    message: "#{field_name} must be specified.",
    code: ShipEngine::Errors::ErrorCode.get(:FIELD_VALUE_REQUIRED)
  )
end