Method: Aws::Errors::DynamicErrors#error_class

Defined in:
lib/aws-sdk-core/errors.rb

#error_class(error_code) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Given the name of a service and an error code, this method returns an error class (that extends ServiceError.

Aws::S3::Errors.error_class('NoSuchBucket').new
#=> #<Aws::S3::Errors::NoSuchBucket>


367
368
369
370
371
372
373
374
375
376
377
378
# File 'lib/aws-sdk-core/errors.rb', line 367

def error_class(error_code)
  constant = error_class_constant(error_code)
  if error_const_set?(constant)
    # modeled error class exist
    # set code attribute
    err_class = const_get(constant)
    err_class.code = constant.to_s
    err_class
  else
    set_error_constant(constant)
  end
end