Skip to content

Commit 8565e06

Browse files
committed
Include invalid status code when raising error
1 parent 8f9f4c1 commit 8565e06

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Edge
44

5+
- include invalid status code when raising handshake error
6+
57
## 1.2.11
68

79
- remove unused base64 require that would cause issues in Ruby 3.4

lib/websocket/error.rb

+6
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ def message
108108
end
109109

110110
class InvalidStatusCode < ::WebSocket::Error::Handshake
111+
attr_reader :invalid_status_code
112+
113+
def initialize(invalid_status_code)
114+
@invalid_status_code = invalid_status_code
115+
end
116+
111117
def message
112118
:invalid_status_code
113119
end

lib/websocket/handshake/client.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def parse_first_line(line)
123123
line_parts = line.match(FIRST_LINE)
124124
raise WebSocket::Error::Handshake::InvalidHeader unless line_parts
125125
status = line_parts[1]
126-
raise WebSocket::Error::Handshake::InvalidStatusCode unless status == '101'
126+
raise WebSocket::Error::Handshake::InvalidStatusCode.new(status) unless status == '101'
127127
end
128128
end
129129
end

0 commit comments

Comments
 (0)