Skip to content

Commit f47889b

Browse files
Introduce Protocol::HTTP::RequestRefusedError.
1 parent 6b9b3d8 commit f47889b

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

lib/protocol/http/error.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ module HTTP
99
class Error < StandardError
1010
end
1111

12+
# Raised when a request was not processed by the server and can be safely retried, even for non-idempotent methods.
13+
class RequestRefusedError < Error
14+
end
15+
1216
# Represents a bad request error (as opposed to a server error).
1317
# This is used to indicate that the request was malformed or invalid.
1418
module BadRequest

releases.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Releases
22

3+
## Unreleased
4+
5+
- Introduce `Protocol::HTTP::RequestRefusedError` for indicating a request was not processed by the server and can be safely retried.
6+
37
## v0.60.0
48

59
- Expose `Protocol::HTTP::Body::Writable#count` attribute to provide access to the number of chunks written to the body.

test/protocol/http/error.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55

66
require "protocol/http/error"
77

8+
describe Protocol::HTTP::RequestRefusedError do
9+
let(:error) {subject.new("GOAWAY: request not processed.")}
10+
11+
with "#initialize" do
12+
it "is an HTTP error" do
13+
expect(error).to be_a(Protocol::HTTP::Error)
14+
end
15+
16+
it "has a descriptive message" do
17+
expect(error.message).to be == "GOAWAY: request not processed."
18+
end
19+
end
20+
end
21+
822
describe Protocol::HTTP::DuplicateHeaderError do
923
let(:key) {"content-length"}
1024
let(:existing_value) {"100"}

0 commit comments

Comments
 (0)