Exception: Callapi::Errors
- Inherits:
-
StandardError
- Object
- StandardError
- Callapi::Errors
- Defined in:
- lib/callapi/errors.rb
Constant Summary collapse
- STATUS_TO_ERROR_CLASS =
{ 401 => 'NotAuthorizedError', 404 => 'NotFoundError' }
Class Method Summary collapse
Class Method Details
.error_by_status(status) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/callapi/errors.rb', line 6 def self.error_by_status(status) error_class_name = STATUS_TO_ERROR_CLASS[status] unless error_class_name error_class_name = case status when 500..599 then 'ServerError' when 400..499 then 'ClientError' when 300..399 then 'RedirectionError' else 'ServerError' end end Kernel.const_get "Callapi::#{error_class_name}" end |