Class: X::StreamError
- Inherits:
-
X::Streaming::Error
- Object
- Error
- X::Streaming::Error
- X::StreamError
- Defined in:
- x-streaming/lib/x/streaming/stream_error.rb
Overview
Raised for a line of a stream that holds errors and no data
A stream sends the problems it has in a line of their own, such as the operational-disconnect X sends before it closes a stream. The line is not an object the stream delivers, so the stream raises this error in place of passing it to its block, whether the objects are Hashes or are built by an object_class.
A stream reconnects after a line that holds operational-disconnects alone, as it does after a connection that dropped, and raises this error once it has no reconnects left. After any other problems it stops, and the error reaches the caller, who decides whether to open the stream again. The message names the request, and each problem, and #problems holds them, as X::HTTPError#problems holds those of a response the API refused. #http_method and #uri are the request of the stream.
Instance Attribute Summary collapse
-
#http_method ⇒ Symbol?
readonly
The HTTP method the request of the stream was sent with.
-
#problems ⇒ Array<Problem>
readonly
The problems the line of the stream held.
-
#uri ⇒ URI::Generic?
readonly
The URI the request of the stream was sent to.
Instance Method Summary collapse
-
#initialize(message = nil, problems: [], http_method: nil, uri: nil) ⇒ StreamError
constructor
Initialize a new StreamError.
Constructor Details
#initialize(message = nil, problems: [], http_method: nil, uri: nil) ⇒ StreamError
Initialize a new StreamError
Public, so that code that rescues a StreamError can be tested with one built by hand, as StreamParser builds one for a line of a stream, and raised with a message alone, as any exception is. The message is the one given, or else the title and detail of each problem, and names the request, when given its method and URI, as the errors of x-core name the request that raised them.
69 70 71 72 73 74 |
# File 'x-streaming/lib/x/streaming/stream_error.rb', line 69 def initialize( = nil, problems: [], http_method: nil, uri: nil) @problems = problems.dup.freeze @http_method = http_method&.downcase&.to_sym @uri = uri super(naming_request( || describe(problems))) end |
Instance Attribute Details
#http_method ⇒ Symbol? (readonly)
The HTTP method the request of the stream was sent with
34 35 36 |
# File 'x-streaming/lib/x/streaming/stream_error.rb', line 34 def http_method @http_method end |
#problems ⇒ Array<Problem> (readonly)
The problems the line of the stream held
50 51 52 |
# File 'x-streaming/lib/x/streaming/stream_error.rb', line 50 def problems @problems end |
#uri ⇒ URI::Generic? (readonly)
The URI the request of the stream was sent to
42 43 44 |
# File 'x-streaming/lib/x/streaming/stream_error.rb', line 42 def uri @uri end |