Coder Social home page Coder Social logo

Comments (6)

ahyatt avatar ahyatt commented on July 18, 2024

You can check for errors with condition-case. If the websocket cannot connect, re-opening with websocket-open seems like the safest thing to do.

from emacs-websocket.

cireu avatar cireu commented on July 18, 2024

Can you try this piece of code?

aria2c --enable-rpc --rpc-listen-port=6800
(condition-case _ (setq ws (websocket-open "ws://localhost:6800/unreachable)) (message "Error!"))

The condition-case won't work because you can connect to the server but you will get 404 response because unreachable doesn't exist, You will get

error in process filter: condition-case: Error response received from websocket server
error in process filter: Error response received from websocket server

The error was raised by websocket-outer-filter at https://github.com/ahyatt/emacs-websocket/blob/master/websocket.el#L789 asynchronously.

IMO, it shuold be possible to handle these errors by using callback, force throwing errors is not so user-friendly.

from emacs-websocket.

ahyatt avatar ahyatt commented on July 18, 2024

I see - yeah that's a problem. After some investigation, I have a potential fix in the new error-fix branch: 0591322. With this, you should be able to handle an error in whatever you set to on-error. I'm not sure this fix is complete good - it probably should throw if on-error is not set. I'll have to think about that case...

In any case, please try this out and let me know if the solution works for you.

from emacs-websocket.

cireu avatar cireu commented on July 18, 2024

Thanks you, this works for me.

It seems that default error-handler is websocket-default-error-handler, why not just throw the error in that function?

from emacs-websocket.

ahyatt avatar ahyatt commented on July 18, 2024

Cool, this has been merged into the master branch, along with some other error issues I noticed.

from emacs-websocket.

cireu avatar cireu commented on July 18, 2024

thx for your work

from emacs-websocket.

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.