Module: Aws::Errors::DynamicErrors Private
- Included in:
- SSO::Errors, SSOOIDC::Errors, STS::Errors
- Defined in:
- lib/aws-sdk-core/errors.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
This module is mixed into another module, providing dynamic error classes. Error classes all inherit from ServiceError.
# creates and returns the class
Aws::S3::Errors::MyNewErrorClass
Since the complete list of possible AWS errors returned by services is not known, this allows us to create them as needed. This also allows users to rescue errors by class without them being concrete classes beforehand.
Class Method Summary collapse
- .extended(submodule) ⇒ Object private
Instance Method Summary collapse
- #const_missing(constant) ⇒ Object private
-
#error_class(error_code) ⇒ Object
private
Given the name of a service and an error code, this method returns an error class (that extends ServiceError.
Class Method Details
.extended(submodule) ⇒ 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.
348 349 350 351 |
# File 'lib/aws-sdk-core/errors.rb', line 348 def self.extended(submodule) submodule.instance_variable_set('@const_set_mutex', Mutex.new) submodule.const_set(:ServiceError, Class.new(ServiceError)) end |
Instance Method Details
#const_missing(constant) ⇒ 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.
353 354 355 |
# File 'lib/aws-sdk-core/errors.rb', line 353 def const_missing(constant) set_error_constant(constant) end |
#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>
364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/aws-sdk-core/errors.rb', line 364 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 |