Git Product home page Git Product logo

Comments (13)

mhulse avatar mhulse commented on June 26, 2024

https://github.com/i0natan/nodebestpractices#-22-use-only-the-built-in-error-object

from basic-node-module.

mhulse avatar mhulse commented on June 26, 2024

Great examples here:

https://github.com/sindresorhus/p-queue/blob/37c1204cc68e54f9d4ecf4e5200eb9313fd277be/index.js#L69-L79

from basic-node-module.

mhulse avatar mhulse commented on June 26, 2024

Good advice here: https://stackoverflow.com/a/52215925/922323

from basic-node-module.

mhulse avatar mhulse commented on June 26, 2024

This talks about how to use top-level caller:

https://stackoverflow.com/a/48685979/922323

from basic-node-module.

mhulse avatar mhulse commented on June 26, 2024

Sync way: https://stackoverflow.com/questions/30367395/how-to-catch-errors-in-synchronous-functions-in-node-js

from basic-node-module.

mhulse avatar mhulse commented on June 26, 2024

This is interesting:

https://makandracards.com/makandra/43653-javascript-don-t-throw-exceptions-from-async-functions

TLDR: A function is hard to use when it sometimes returns a promise and sometimes throws an exception. When writing an async function, prefer to signal failure by returning a rejected promise.

from basic-node-module.

mhulse avatar mhulse commented on June 26, 2024

I need to make a readme wiki repo on exception handling, just for my own education. This shit is probably one of the more complex/ambiguous feature(?) of es6+ (in my mind).

Just need more practice. :)

from basic-node-module.

mhulse avatar mhulse commented on June 26, 2024

Looks like thowing a new error will result in a rejected promise in a async/await.

https://stackoverflow.com/a/42453705/922323

from basic-node-module.

mhulse avatar mhulse commented on June 26, 2024

A few good paragraphs about constructors and async operations; basically, don't do that in constructor.

from basic-node-module.

mhulse avatar mhulse commented on June 26, 2024

Great tips here:

https://eloquentjavascript.net/08_error.html

Another way to set a breakpoint is to include a debugger statement (consisting of simply that keyword) in your program. If the developer tools of your browser are active, the program will pause whenever it reaches such a statement.

If you’re programming only for yourself, you can afford to just ignore such problems until they occur. But if you build something that is going to be used by anybody else, you usually want the program to do better than just crash. Sometimes the right thing to do is take the bad input in stride and continue running. In other cases, it is better to report to the user what went wrong and then give up. But in either situation, the program has to actively do something in response to the problem.

from basic-node-module.

mhulse avatar mhulse commented on June 26, 2024

https://medium.com/@xjamundx/custom-javascript-errors-in-es6-aa891b173f87

from basic-node-module.

mhulse avatar mhulse commented on June 26, 2024

Good tips here:

https://stackoverflow.com/a/42171508/922323

from basic-node-module.

mhulse avatar mhulse commented on June 26, 2024

Returning a promise from async will not double wrap the promise:

https://stackoverflow.com/a/35302535/922323

Non-promise return will be wrapped.

No return will return a promise.

from basic-node-module.

Related Issues (7)

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.