Providing Friendly Error Messages

Team Fly 

Page 656

If you want your custom message to really stand out in the trace listing, substitute Trace.Warn for Trace.Write. Tracing can be a special tool when debugging because of the wealth of information it provides, and because it shows you a complete list of all the steps that took place during execution, their order, and their duration.

Tracing tells you these primary facts:

image How long each step takes in milliseconds (you can quickly see if there are any significant delays, or use this information to optimize your application)

image Which processes executed

image Any error messages, and specific details about these errors

image Custom trace messages you insert, along with variable values if you wish to add them (illustrated above)

image Details about variables used in the project

image Specifications about the containers and controls on each page

image Specifications about when requests happened

Trace Information Sections

When you request a trace you see six major divisions, but the Trace Information section is most often the most useful information. The Request Details section simply identifies the HTTP request type and other data about the request such as the type of character encoding (usually Unicode), when the request was made, and so on. The Control Tree lists server controls that may be on your page, and also lists child controls. If you're tracing an ordinary ASP.NET page, you would see a Cookies Collection section, but this isn't displayed for a mobile application. Instead, you see a Session State section that displays the Session ID. The Headers Collection zone lists the HTTP headers that your server sent to the client device. In ordinary ASP.NET applications, this section also includes cookie information. Finally, the Server Variables section describes your server in considerable detail, identifies quite a bit about the state of your server—its URL, connection type, and so on.

Providing Friendly Error Messages

You always want to avoid frightening your users with lengthy, technical error messages such as Object Not Found or Stack Collapse. They'll think their PDA is broken, or their phone is about to explode. Never underestimate the confusion and fear that the average person experiences after punching some buttons on a high-tech device. If anything unusual happens, many of them think they must have accidentally entered the activation code.

In ordinary Windows applications, you can intercept error messages and, instead of letting users see them, substitute your own user-friendly descriptions displayed in message boxes. MsgBox doesn't work in ASP.NET applications, though. You have to employ a different tactic. Find this section in Web.config :

 <!-- CUSTOM ERROR MESSAGES 
Team Fly 


Visual Basic  .NET Power Tools
Visual Basic .NET Power Tools
ISBN: 0782142427
EAN: 2147483647
Year: 2003
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net