« Learning XPages Part 40 : Two Data Sources One Xpage | Main| YTRIA Lotus Notes Tools Updated to version 8.5 »

Learning XPages Part 41 : Debugging Your Code

Tags : Lotus Domino XPages
Bookmark : del.icio.us  Technorati  Digg This  Add To Furl  Add To YahooMyWeb  Add To Reddit  Add To NewsVine 

Over the course of the series we have been using some small snippits of JavaScript to compute the values of properties and labels on our XPage. A lot of our JavaScript so far has followed styles that we are familiar with in LotusScript and Formula language but we have had to make some subtle changes so that it would fit within the conventions of the JavaScript language.

When developing your XPage application you may have come across 'Error 500' in your web browser, how it appears to you depends on the web browser you are using.

A picture named M2

The normal cause of this error is a problem with your JavaScript code that was executing on the server. The error message above doesn't really help you beyond knowing the fact that there was an error.

If you look at the application properties for your database there is a section for errors and timeouts in the xpages tab.  Turn on the 'Display default error page' option.

A picture named M3

Now if you save the application properties and refresh your XPage that was giving you the error you should see a much more helpful error page :

A picture named M4

It's still not perfect, the page name above is not exactly where the error is. In this case I purposely caused my error in the content_HomePage custom control but the rest of the error message really does help me pinpoint exactly where the error occurred and knowing what line of code caused the error can help you fix it quickly. In this case I used GetColumnValue instead of getColumnValue.

Once your finished your XPages application you may want to turn that application property back off incase a user causes some sort of error. I don't know about you but I'd rather my users didn't see such detailed error messages. I'd prefer to keep it nice and simple for them and the XPages processor allows us to do that also.

Back in the application properties you can select an XPage to be displayed if there is an error. This could be a simple 'An Error Has Occurred, Click here to return to the homepage' type XPage or you could have a form asking the user to enter in what they were doing and then you can email that to the application developer. The options are limitless. here's an option where I redirect to a debug xpage.

A picture named M5

My debug page shows me the values of all the session and application scope variables at the time of the error and the page will be included in the next downloadable version of the database.

Comments

Gravatar Image1 - HI Dec
I have copied all the Parts to ODF & Word doc if you like to add it to your side for download - let me know Emoticon

Gravatar Image2 - Man, this is redbook material. I really appreciate all the efforts you put in to share your xpages knowledge. Training material is slowly popping up here and there, but your articles are just amazing.

Keep up the good work, and maybe you could create a PDF file and sell it for cheap!!! I know I'd pay to get that PDF, even if all of your articles are available free of charge on your blog.

Emoticon

Gravatar Image3 - I am stuck because after adding code for the previous entry, I keep getting the error 500 message. Checking "Display default error page" does not show the error details, even after 3 days and a server restart. It's funny that the page loaded fine just after I made the changes, but after 5 clicks on different locations, it started erroring with no code changes.