Try using the Server.GetLastError() method.
From MSDN link:
The GetLastError method returns an ASPError Object describing the error condition that occurred. This method is available only before the .asp file has sent any content to the client.
This article on CodeProject has a pretty good tutorial on error handling in ASP.net.