I have built a number of custom modules and they work fine as long as there is no error. The error trapping works fine too. The only issue that I have is that when using exit() to display a message and stop the php page from running - it displays the page outside of Joomla rather then in the module location.
You can see an example of this behavior at: http://www.p3proswing.com/site3/index.php/p3-live-home
I would want this error to appear within the main body of Joomla (like the module does when you are logged in). Thus, the header, menu, footer, etc. should all still be displayed.