Moving to production, really need better error handling

Topics: Web Api
Sep 30, 2011 at 9:14 PM

Hey,

Despite the fact that I can't sort out the error handling (I throw an exception from within an API method, but the client always recieves the 500 error) I'm planning on moving this forward to production next week. Is there any way I can sort out a better error generation method?

In my service code, I'm just currently throwing normal exceptions with messages like:

"Patient not found"

but they all translate to the 500 "Please check the server logs." error. Can anyone help? I've tried everything I can find, but most of it only works for the old wcf rest starter kit .. and doesn't quite translate.

Coordinator
Oct 7, 2011 at 7:28 AM

You have a couple of options:

1. Throw HttpResponseException from your operations and specify the details of the error response that you want sent

2. Configure an HttpErrorHandler for your operations using the ErrorHandlers property on your HttpConfiguration instance. Your HttpErrorHandler can then handle mapping exceptions to HTTP error codes and responses.

Hope this helps.

Daniel Roth

From: djbyter [email removed]
Sent: Friday, September 30, 2011 1:15 PM
To: Daniel Roth
Subject: Moving to production, really need better error handling [wcf:274434]

From: djbyter

Hey,

Despite the fact that I can't sort out the error handling (I throw an exception from within an API method, but the client always recieves the 500 error) I'm planning on moving this forward to production next week. Is there any way I can sort out a better error generation method?

In my service code, I'm just currently throwing normal exceptions with messages like:

"Patient not found"

but they all translate to the 500 "Please check the server logs." error. Can anyone help? I've tried everything I can find, but most of it only works for the old wcf rest starter kit .. and doesn't quite translate.

Oct 20, 2011 at 7:04 AM

Hey,

You may want to see my second post in http://wcf.codeplex.com/discussions/276528 where I describe a suitable error handler for production.

Regards,

Andrew