All Questions
Tagged with node.js error-handling
20 questions
2
votes
1
answer
177
views
Command handlers in node.js
Description
This javascript code uses tmi.js to listen for chat messages in a Twitch chat and perform certain actions depending on their content. In the sample code ...
2
votes
0
answers
297
views
JavaScript proxy for better stack traces from external libraries
I've been using the excellent pg-promise library for a few years now, but my primary irk with it is that the stack traces are sometimes unhelpful. For example, the following test will fail (currently ...
6
votes
1
answer
1k
views
Implementation of exponential backoff algorithm
You can read about the algorithm here.
An exponential backoff algorithm retries requests exponentially, increasing the waiting time between retries up to a maximum backoff time. An example is:
Make ...
2
votes
0
answers
31
views
Error handling in express without middlewares and using class structure
This is a simple implementation of Django's sample project "Poll" using and express.
The controller code:
...
3
votes
1
answer
7k
views
Retry a Promise resolution N times, with a delay between the attempts
I want some JavaScript code to take 3 things as parameters:
A function returning a Promise.
The maximum number of attempts.
The delay between each attempt.
What I ended up doing is using a ...
4
votes
1
answer
1k
views
Node.js http retry do while mechanism
I have implemented a simple do/while loop to handle a http request to a third-party. I don’t know when the data I receive will have elements in its array so I retry up to 10 times until the array ...
0
votes
1
answer
132
views
#Error Handling- Propagating errors to calling function.
Im new to javascript programming and i am required to make a web app. Node.js will be used as the js runtime environment. In order to minimize the amount of time needed for debugging as the app ...
1
vote
2
answers
113
views
Error handling for a simple 'fetch some data, then save the data' Node function
This is a fairly simple bit of code:
...
0
votes
2
answers
1k
views
Node.js error handling using merely if else without try catch
I'm confused why you need to use try catch. I made a simply utils like this, and use it on my models' callback.
in my utils/error.js
...
1
vote
1
answer
182
views
Hello World Node application with error handling
I wrote this simple server in node. Actually my goal is to better understand exception handling best practices in Node.
So my question is more specific.
Is this code bullet proof to exceptions? Are ...
3
votes
0
answers
261
views
Keeping error details out of responses (Restify)
I'd like to make sure error details are never sent out in responses from my restify-powered API. The best way to achieve that seemed to be via wrapping server.formatters in another function which ...
4
votes
1
answer
1k
views
Loading a database table using a promise chain
I am creating a util module that I'm using to communicate with a MS-SQL database. I want each public method to return a promise. I started with a private function that executes a DB query and returns ...
4
votes
1
answer
81
views
Continuable if error is null
I made a method that I can use to avoid having to handle errors from callbacks.
What it does is, call the passed method only if the first argument is null.
So essentially it will bypass to the last ...
3
votes
0
answers
157
views
Sourcemap translator service
This is my first attempt to a serious Node.js application, I've tried to follow the async style of Node at my best, but I have several doubts and I am sure that this code can be massively improved.
...
4
votes
2
answers
180
views
Querying MongoDB for information on a collection of books
I have this huge chunk of code. Is there any better to write this code, or am I too paranoid that I check every MongoDB query for error?
The logic is here:
...