When you develop on SharePoint, you may often get this annoying error "An unexpected error has occurred" without knowing what is causing your errors.
To get more detail what errors you get, you have to do a few things in your web.config of your SharePoint site.
First, change the default settings attribute CallStack from SafeMode tag from false to true
<SafeMode CallStack="true" ...
Second, change the default settings attribute mode from customErrors tag from on to off
<customErrors mode="Off" />
After that, SharePoint should give you specific error message if you encounter errors.
I get this great tips from this blog . You can find more details there.
All the credits should go to the original poster.