“An unexpected error has occurred”: the sharepoint developer nightmare

24 04 2008

If you are developing with WSS/MOSS, this is a known message. A lot of unexpected errors are displayed simply as “An unexpected error has occurred.”. Some of them you can debug in the sharepoint log files, some of them you can find details in the event log, and some… you can’t find anything… those are pure and simple desperation until you hit with your head enough times to almost develop a 6th sense; with this sense you start guessing where the problem comes from.

The biggest problem about this type of errors is that the debug process is VERY time consuming.

Well, today I came across a very smart approach for this problem. You just implement a HTTPModule that catches the exception prior to being treated by MOSS and logs it where ever you want.

This great approach was developed by Janne Mattila  and you can find the full post here: http://blogs.msdn.com/jannemattila/archive/2008/02/04/catching-unhandled-exceptions-in-sharepoint.aspx

Great work!

Advertisements

Actions

Information

5 responses

22 11 2008
sethuram

hello,
i am facing the problem… i created new web appln and it was done successfully ,,, but when i tried to logging in it was throwing an error as u specified. what i need to do now? please let me know..

22 11 2008
ruimelo

Sethuram,
the main problem you need to face is which error is causing this, as this message is kind of a generic error message. Try following the link above to implement the trace that will surface the inner exception causing the problem.
You can also look into the logs (c:\program files\common files\Miscrosoft Shared\web server extensions\12\logs) and look for exceptions and errors.

Also take a peek at the event viewer. sometimes you can find usefull information there.

In las tesources, windbg may be required to figure out the problem. Lets hope not..

Hope this helps

15 01 2009
Debuging WSS 3/MOSS 2007 « Stepping stones for crossing technological ponds

[…] an HttpModule to handle exceptions of type “An unknow error has occured.”. Here is a post whith that […]

14 09 2009
Mohamed Hachem

Hello

To see the call stack go to the web config of the current application and do teh following :

1) Set call Stack to true

2) Set Custom Error display to Off

This will allow you to see the error

quick repair would be to recycle the pool and sharepoint timer 😉

cheers

14 09 2009
ruimelo

Hi Mohamed,

Thank you for your input!

Indeed this approach will let you
see the error

, but that’s it. It is
very useful

but in dev environments only.

The posting I’m referring allows you to grab the exception and treat it (i.e log it to your log, redirect to a certain page, etc.).

Also the App Pool recycling is not a solution.
If the problem was generated by coding error, the problem will not be solved by recycling App Pools…

Cheers!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: