Skip to content

Commit

Permalink
Updated: Rethrow errors so they may be handled outside of WebSocket.o…
Browse files Browse the repository at this point in the history
…pen() (#1072)

* Rethrow error in websocket

* Don't throw when closed normally

https://github.com/JuliaWeb/HTTP.jl/pull/1069/files#r1247308928

* Also rethrow when upgrading websocket
  • Loading branch information
Zentrik authored Apr 6, 2024
1 parent 4693a9b commit 7a913fb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/WebSockets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ function open(f::Function, url; suppress_close_error::Bool=false, verbose=false,
close(ws, CloseFrameBody(1008, "Unexpected client websocket error"))
end
end
if !isok(e)
rethrow()
end
finally
if !isclosed(ws)
close(ws, CloseFrameBody(1000, ""))
Expand Down Expand Up @@ -452,6 +455,9 @@ function upgrade(f::Function, http::Streams.Stream; suppress_close_error::Bool=f
close(ws, CloseFrameBody(1011, "Unexpected server websocket error"))
end
end
if !isok(e)
rethrow()
end
finally
if !isclosed(ws)
close(ws, CloseFrameBody(1000, ""))
Expand Down

0 comments on commit 7a913fb

Please sign in to comment.