Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
what is good practice dealing with exceptions?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Angelo Chen  
View profile  
 More options Jul 17 2012, 12:46 am
From: Angelo Chen <angelochen...@gmail.com>
Date: Mon, 16 Jul 2012 21:46:48 -0700 (PDT)
Local: Tues, Jul 17 2012 12:46 am
Subject: what is good practice dealing with exceptions?
Hi,

In Java web apps, if an exception happens, only that user experience
it, other does not, thanks to its multi thread nature, and yet, the
program will never terminate, but simply goes back, allow you to
refresh or do something else.

In node/express, like following code:

exports.query_card = (req, res) ->
        dao.get_card req.params.key, (err, card) ->
          res.json({ status:'OK',  flag: card.flag});

if the card is null, it will display this then program terminates:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first
tick
              ^
TypeError: Cannot read property 'closed' of null

run it under NODE_ENV=production, same result,

I know i need to check if it's null first before using it, but is
there some way to keep it running without terminating? using Forever/
Monit is one option, however it's different, it restarts the app, not
keeping the app running after exception, ideas?

Thanks,

Angelo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott  
View profile  
 More options Jul 17 2012, 1:38 am
From: Scott <sheb...@gmail.com>
Date: Mon, 16 Jul 2012 22:38:49 -0700
Local: Tues, Jul 17 2012 1:38 am
Subject: Re: [Express-js] what is good practice dealing with exceptions?
One thing I did that helped a lot is add this to app.js (in production
I have it send me an email notice):

process.addListener("uncaughtException", function (err) {
    console.log("Uncaught exception: " + err);
    console.trace();

});

Scott


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angelo Chen  
View profile  
 More options Jul 17 2012, 2:36 am
From: Angelo Chen <angelochen...@gmail.com>
Date: Mon, 16 Jul 2012 23:36:24 -0700 (PDT)
Local: Tues, Jul 17 2012 2:36 am
Subject: Re: what is good practice dealing with exceptions?
Hi Scott,

Thanks for sharing, I added that and exception got caught, then it
just stop there until I press Ctrl C to terminate the app,

process.addListener "uncaughtException",  (err) ->
        console.log("Uncaught exception: " + err)

i think that's a good place to email me the problem, but after that?

On Jul 17, 1:38 pm, Scott <sheb...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas White  
View profile  
 More options Jul 17 2012, 4:44 am
From: Thomas White <thomas.0...@gmail.com>
Date: Tue, 17 Jul 2012 09:44:00 +0100
Subject: Re: [Express-js] Re: what is good practice dealing with exceptions?

Angelo,

I am not sure what is the context for you question: what is the use case
and the are the actions you would like to take when an error occurs?

If you are asking "I just want to write a very light code without any
data sanitizing, without checking the result of operation that may cause an
error and exception and without taking care to recover from an error" then
using a global event listener for errors is fine, especially when we write
a quick and dirty throwaway code.

On other hand implementing a generic data sanitizer is relatively simple
and having an error handler that will allow you to recover from a specific
error in a specific context and take appropriate actions according to the
business logic, data flow and user experience makes more sense to me and
will have much more value in a long run.

Another approach will be to create a global context object and update it
when you go to the next step of your logic. This will allow the global
error handler can take into account the state when the error toke place,
and react accordingly.

I hope this helps.

Thomas

Thomas

------

On 17 July 2012 07:36, Angelo Chen <angelochen...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angelo Chen  
View profile  
 More options Jul 18 2012, 12:03 am
From: Angelo Chen <angelochen...@gmail.com>
Date: Tue, 17 Jul 2012 21:03:06 -0700 (PDT)
Local: Wed, Jul 18 2012 12:03 am
Subject: Re: what is good practice dealing with exceptions?
after some research, basically when uncaughtException occurs, the safe
approach is restart, adding that listener helps troubleshooting,
thanks.

On Jul 17, 1:38 pm, Scott <sheb...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »