Handling process errors

39 views
Skip to first unread message

Ingwie Phoenix

unread,
Sep 5, 2014, 12:10:41 AM9/5/14
to nod...@googlegroups.com
Hey.

I have successfuly implemented an automatically updating nodejs web app. Now, I want to make sure it doesnt crash on minimal failures (when i derped in a function and tried to access a property with a simple typo). So I looked up what options I had:

- process’ „uncaughtException“ event
- Domains

In either case, I get the base idea of it. But what I dont get, is any information on the structure of an Error object. I also have another concern:

When I want to restart my app, as it is described in the domains page int he docs, I know that require() caches scripts. How can I flatten this cache first?

I looked into some nodejs modules, but I couldn’t find a „really great“ error handling module, that would tell me exactly whats up.

Is there anything you guys could recommend?

Kind regards,
Ingwie

Luca Morandini

unread,
Sep 8, 2014, 11:38:46 AM9/8/14
to nod...@googlegroups.com
On 05/09/14 13:17, Ingwie Phoenix wrote:
>
> In either case, I get the base idea of it. But what I dont get, is any
> information on the structure of an Error object.

This is a V8 object, and it contains -to the best of my knowledge:
- name (type of error);
- message (the string you pass to the constructor);
- stack (the stack trace).

Like in:
> var error = new Error("My error message");
> error.name
'Error'
> error.message
'My error message'
> error.stack
'Error: My error message\n at repl:1:13\n at REPLServer.self.eval
(repl.js:110:21)\n at repl.js:249:20\n at REPLServer.self.eval
(repl.js:122:7)\n at Interface.<anonymous> (repl.js:239:12)\n at
Interface.EventEmitter.emit (events.js:95:17)\n at Interface._onLine
(readline.js:202:10)\n at Interface._line (readline.js:531:8)\n at
Interface._ttyWrite (readline.js:760:14)\n at ReadStream.onkeypress
(readline.js:99:10)'

Of course, once created, you can add more properties to it to fit your case.

Regards,

Luca Morandini
Data Architect - AURIN project
Melbourne eResearch Group
Department of Computing and Information Systems
University of Melbourne
Tel. +61 03 903 58 380
Skype: lmorandini

Reply all
Reply to author
Forward
0 new messages