Coder Social home page Coder Social logo

Comments (8)

treeform avatar treeform commented on July 28, 2024 1

Please update the examples.

Don't worry about the README, we stopped using mddoc and use nimdocs now. I can change that part after your PR.

from ws.

EriKWDev avatar EriKWDev commented on July 28, 2024

I don't even know if WebsocketClosedError should be an error xP That one seems pretty integral for a websocket server that needs to keep track of connections.

Should it perhaps just be called WebsocketClosed? WebsocketClosedExcpetion?
Doesn't really matter but hey, semantics in programming sure is fun...

from ws.

treeform avatar treeform commented on July 28, 2024

Basically any exception from the websocket is a close. Would you handle WebSocketProtocolMismatchError, WebSocketHandshakeError differently?

I think close should be an exception as the expected path for web socket to remain open forever.

from ws.

EriKWDev avatar EriKWDev commented on July 28, 2024

While I see what you mean, I also think that a specific error as possible should be raised. I checked the test cases and a bunch of them except WebSocketError and assume that the thing that went wrong is in fact what the test is for, but with that mentality we might as well just raise Exception since "it wouldn't be handled differently anyway" xP The test for protocol doesn't even except WebSocketError just 'except:' and then compares the error message. This seems unacceptable? a WebSocketProtocolMismatchError would be a better solution here.

If the new exceptions are all of 'object of WebSocketError', old try-excepts would still work like they already do and the tests could become more specific. It wouldn't cost anything but would allow for cleaner code.

Some code duplication could go away as well since the WebSocketClosedError is raised in quite a few places. Perhaps a simple 'newWebSocketClosedError' with the correct message should be made?

from ws.

EriKWDev avatar EriKWDev commented on July 28, 2024

I also beleive that this test (test_protocol_arr) is supposed to find a WebSocketProtocolMismatchError, but the actual WebSocketError being raised here is Failed to Upgrade (Possibly Connected to non-WebSocket url since the cb() responds with 404. Is this correct?

from ws.

treeform avatar treeform commented on July 28, 2024

I would not mind WebSocketError hierarchy with WebsocketClosed, WebSocketProtocolMismatchError etc... I don't need it though, so I will not make this myself, but PRs welcome.

My fear is that we add this complexity but its not used by anyone in real production system and just creates a bigger bug surface.

from ws.

EriKWDev avatar EriKWDev commented on July 28, 2024

Well, I believe that having more specific errors does the opposite of creating a bigger bug surface since it allows for better tests and debugging.

Users can still just except WebSocketError if they don't care and catch them all.

I'll make a PR since I do want this for myself anyway :)

Should the README be updated as well to contain the new Errors? Should the chatserv er example still use except: WebSocketErrorfor the closing sockets or should it specifically except WebSocketClosedError?

from ws.

treeform avatar treeform commented on July 28, 2024

I updated the read me to our new style. Feel free to mess with it.

from ws.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.