Giter Site home page Giter Site logo

Comments (4)

Gippsman2017 avatar Gippsman2017 commented on June 25, 2024 1

Hi Mathias,
Some thoughts,
Probably the best way to really handle errors, is to fix them in alasql, the usage of throw in the src files is where the problem lies, in normal terms, the caller function should handle the error returned from a called function, not the called function bombing out with a "throw error".
So, if any function called, like delete,drop,create,detach etc has an issue, then the cb should be an object containing either a 0/1 and an error message etc.
The caller alasql function can then decide what the next action should be, in the case of core database issues, then a legitimate throw would be used, however in the case of trying to insert into a non-existent database, then an error message is more applicable
Therefore, from a Node-Red point of view, then yes a single object returned on a output is the go.

from node-red-contrib-alasql.

mathiasrw avatar mathiasrw commented on June 25, 2024 1

@Steve-Mcl Good point - and thank you for reminding me.

from node-red-contrib-alasql.

mathiasrw avatar mathiasrw commented on June 25, 2024

I am actually not sure.

How would be a normal way of handling this in other node-red setups? Would it be a specific message out or?

from node-red-contrib-alasql.

Steve-Mcl avatar Steve-Mcl commented on June 25, 2024

Hi all, regardless of error source (your node / alasql) you should try at all costs to prevent crashing node-red

The recommended method for contrib nodes in node-red is...

try {
  //do stuff
} catch (e) {
  node.error(e,msg);
  return; //dont send a msg
}

NOTE: for promises, use the .catch mechanism to feed errors forward again using node.error(e,msg);

This permits the node-red catch node to catch the error allowing the flow to handle the error appropriately.

Not handling errors in your node can crash node-red - not good.

NOTE: if you wish, you can still send a message (and include the error) but many flow developers will see a message & may not check for a msg.error property. I have in some contrib nodes, provided a UI option to "throw errors" or "add error to msg object"

from node-red-contrib-alasql.

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.