Skip to content

Commit 567e736

Browse files
committed
document and add reason codes for all known websocket errors
1 parent c6c7557 commit 567e736

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

lib/mint/web_socket_error.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ defmodule Mint.WebSocketError do
1010
quote do
1111
:extended_connect_disabled
1212
| :connection_not_upgraded
13+
| :payload_too_large
14+
| {:extension_not_negotiated, Mint.WebSocket.Extension.t()}
1315
end
1416

1517
@type t :: %__MODULE__{reason: unquote(reason_type) | term()}
@@ -28,4 +30,12 @@ defmodule Mint.WebSocketError do
2830
defp format_reason(:connection_not_upgraded) do
2931
"connection not upgraded by remote"
3032
end
33+
34+
defp format_reason(:payload_too_large) do
35+
"frame payload cannot exceed 9,223,372,036,854,775,807 bytes"
36+
end
37+
38+
defp format_reason({:extension_not_negotiated, extension}) do
39+
"the remote server accepted an extension the client did not offer: #{inspect(extension)}"
40+
end
3141
end

0 commit comments

Comments
 (0)