Instead of getting the "user-friendly", but frustrating-to-a-developer message "An error has occurred", use these two steps to receive the actual error when developing in SharePoint. Works for both MOSS and WSS. 
- Show the call stack
 Change
 <SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">
 to
 <SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">
 
- 
Set custom errors to False
 Change
 <customErrors mode="On" />
 to
 <customErrors mode="Off" />