mirror of
https://github.com/goldbergyoni/nodebestpractices.git
synced 2025-10-30 00:57:04 +08:00
Create monitoring
This commit is contained in:
26
sections/errorhandling/monitoring
Normal file
26
sections/errorhandling/monitoring
Normal file
@ -0,0 +1,26 @@
|
||||
# Title
|
||||
|
||||
|
||||
### One Paragraph Explainer
|
||||
|
||||
> Callbacks don’t scale as they are not familiar to most programmers, force to check errors all over, deal with nasty code nesting and make it difficult to reason about the code flow. Promise libraries like BlueBird, async, and Q pack a standard code style using RETURN and THROW to control the program flow. Specifically, they support the favorite try-catch error handling style which allows freeing the main code path from dealing with errors in every function
|
||||
|
||||
|
||||
### Code Example – using promises to catch errors
|
||||
|
||||
```javascript
|
||||
Put code here
|
||||
```
|
||||
|
||||
### Blog Quote: "We have a problem with promises"
|
||||
From the blog pouchdb.com, ranked 11 for the keywords “Node Promises”
|
||||
|
||||
> …And in fact, callbacks do something even more sinister: they deprive us of the stack, which is something we usually take for granted in programming languages. Writing code without a stack is a lot like driving a car without a brake pedal: you don’t realize how badly you need it, until you reach for it and it’s not there. The whole point of promises is to give us back the language fundamentals we lost when we went async: return, throw, and the stack. But you have to know how to use promises correctly in order to take advantage of them.
|
||||
|
||||
### image title
|
||||

|
||||
|
||||
### Blog Quote: "The promises method is much more compact"
|
||||
From the blog gosquared.com, ranked 5 for the keywords “Node.JS error handling”
|
||||
|
||||
> …The promises method is much more compact, clearer and quicker to write. If an error or exception occurs within any of the ops it is handled by the single .catch() handler. Having this single place to handle all errors means you don’t need to write error checking for each stage of the work
|
||||
Reference in New Issue
Block a user