Comments (13)
https://github.com/i0natan/nodebestpractices#-22-use-only-the-built-in-error-object
from basic-node-module.
Great examples here:
from basic-node-module.
Good advice here: https://stackoverflow.com/a/52215925/922323
from basic-node-module.
This talks about how to use top-level caller:
https://stackoverflow.com/a/48685979/922323
from basic-node-module.
Sync way: https://stackoverflow.com/questions/30367395/how-to-catch-errors-in-synchronous-functions-in-node-js
from basic-node-module.
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.
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.
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.
A few good paragraphs about constructors and async operations; basically, don't do that in constructor.
from basic-node-module.
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.
https://medium.com/@xjamundx/custom-javascript-errors-in-es6-aa891b173f87
from basic-node-module.
Good tips here:
https://stackoverflow.com/a/42171508/922323
from basic-node-module.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from basic-node-module.