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

Conversation

bryaan
Copy link

@bryaan bryaan commented Jun 29, 2023

This is a fix for a bug where any errors throw from within WebSocket.open() is hidden from an outer try/catch.

#1067

@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants