Last post Aug 29, 2014 08:25 AM by nagarjunareddy04
Aug 22, 2014 04:31 PM|nagarjunareddy04|LINK
I have created Web API Project and this project is using class library project where all the code is residing. And in the class library project I am throwing business exceptions. I have deployed my project into the server. When an exception was thrown it
is just showing as "an error occurred" but not showing the full exception message.
Please help me out how to solve this. I need to show proper exception message instead of just showing as "an error occurred".
Aug 22, 2014 07:51 PM|PatriceSc|LINK
Have you tried
The point is that you have to explicitely define how you want to show the exception client side likely because:
- this is HTTP so a particular HTTP status might make more sense (ie "not found" or "bad request" rather than "server error occured")
- so that you expose only particular errors for safery reasons
Or could it be your client showing a general error message? Is this a js client ?
Aug 23, 2014 01:57 AM|damienBod|LINK
here's another link that might help you
Aug 27, 2014 04:45 AM|nagarjunareddy04|LINK
Thanks for the Reply,
But my question is that I am throwing business exceptions from my Class library project not from the Services project.
If I use Fiddler for testing it is showing exceptions properly.
But when the services integrated in the web forms using HttpClient then it is showing just as internal server error even though I am throwing proper exception messages.
Aug 27, 2014 09:49 AM|MrFinger|LINK
Check the CustomErrors section in your Web.Config. configuration -> system.web -> customErrors
If it is set to On or RemoteOnly, then the details of the thrown exception will be hidden.
Aug 27, 2014 02:46 PM|damienBod|LINK
This seems correct to me. If you want to display the unhandled error to the client, you can add an ExceptionHandler implementation which displays the error message or whatever in the correct HTTP response.
Aug 29, 2014 08:25 AM|nagarjunareddy04|LINK
I did same thing that I turned off CustomErrors. when I was tested services using fiddler I am able to see exceptions that I am throwing. But When I was consumed my services in the clinet using httpclient it is always showing internal server error (500).