Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rethrow errors so they may be handled outside of WebSocket.open() #1069

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/WebSockets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ function open(f::Function, url; suppress_close_error::Bool=false, verbose=false,
close(ws, CloseFrameBody(1008, "Unexpected client websocket error"))
end
end
rethrow(e)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is rethrow() fine here?

Suggested change
rethrow(e)
rethrow()

I think rethrow(e) is not usually the right choice, per the docs:

help?> rethrow
search: rethrow

  rethrow()

  Rethrow the current exception from within a catch block. The rethrown exception will continue propagation as if it had not been caught.

  │ Note
  │
  │  The alternative form rethrow(e) allows you to associate an alternative exception object e with the current backtrace. However this
  │  misrepresents the program state at the time of the error so you're encouraged to instead throw a new exception using throw(e). In Julia
  │  1.1 and above, using throw(e) will preserve the root cause exception on the stack, as described in current_exceptions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should actually do the rethrowing from inside the !isok block above, since we're currently "throwing" a "closed normally" exception when we get a close notification from the peer socket.

finally
if !isclosed(ws)
close(ws, CloseFrameBody(1000, ""))
Expand Down