Exception: Docker::API::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Docker::API::Error
- Defined in:
- lib/docker/api/errors.rb,
sig/docker/api/core.rbs
Overview
The root of every error this gem raises.
Nothing beneath the abstraction escapes: no Errno, no OpenSSL
exception, no Net:: class and no JSON::ParserError reaches a caller's
rescue clause. The original is always retained as #cause, so nothing is
lost -- but consumers get to rescue one hierarchy instead of coupling
themselves to whichever HTTP library happens to be underneath.
Direct Known Subclasses
ClientError, ConnectionError, ServerError, StreamError, TimeoutError, VersionUnsupported
Instance Attribute Summary collapse
-
#operation ⇒ String?
readonly
The operation that failed, e.g.
-
#response ⇒ Docker::API::Response?
readonly
The response, when there was one.
-
#status ⇒ Integer?
readonly
The HTTP status the daemon returned.
Class Method Summary collapse
-
.for(status:, operation: nil, response: nil) ⇒ Docker::API::Error
Build the error class appropriate to an HTTP status.
Instance Method Summary collapse
-
#initialize(message = nil, operation: nil, status: nil, response: nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message = nil, operation: nil, status: nil, response: nil) ⇒ Error
Returns a new instance of Error.
36 37 38 39 40 41 |
# File 'lib/docker/api/errors.rb', line 36 def initialize( = nil, operation: nil, status: nil, response: nil) @operation = operation&.to_s @status = status @response = response super( || ) end |
Instance Attribute Details
#operation ⇒ String? (readonly)
Returns the operation that failed, e.g. "container_start".
24 25 26 |
# File 'lib/docker/api/errors.rb', line 24 def operation @operation end |
#response ⇒ Docker::API::Response? (readonly)
Returns the response, when there was one.
30 31 32 |
# File 'lib/docker/api/errors.rb', line 30 def response @response end |
#status ⇒ Integer? (readonly)
Returns the HTTP status the daemon returned.
27 28 29 |
# File 'lib/docker/api/errors.rb', line 27 def status @status end |
Class Method Details
.for(status:, operation: nil, response: nil) ⇒ Docker::API::Error
Build the error class appropriate to an HTTP status.
49 50 51 |
# File 'lib/docker/api/errors.rb', line 49 def self.for(status:, operation: nil, response: nil) klass_for(status).new(nil, operation: operation, status: status, response: response) end |