Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Exception handling in WRT

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic, Nokia 6220 clasic
Platform(s): S60 5th Edition, S60 3rd Edition, FP2
Keywords: widget.setNavigationEnabled(), alert
Created: ivruban (29 Jan 2009)
Last edited: hamishwillee (10 Oct 2012)



This code snippet shows how to use exception handling mechanism in widget. Exception rise in riseException() function, because of variable "somevar" is not defined earlier. To fix code just add "var somevar=0;" before alert function in riseException().

Source file: Relevant HTML components

<input type="button" value = "Rise exception" 
onclick = "riseException();"></input>

Source file: JavaScript file

window.onload = init;
// Initializes the widget
function init() {
try {
//Disabling navigation, cursor will not be shown.
} catch(exception) {
document.getElementById("result").value = exception;
function riseException() {
} catch (exception){
document.getElementById("result").innerHTML = exception;


To appear exception click on "Rise exception" button.

Supplementary material

  • You can test the exception habdling in action in a simple, executable application into which this code snippet has been patched. The executables and source files are available for download at:‎.
  • You can examine all the changes that are required to implement the above mentioned features in an application. The changes are provided in unified diff and color-coded diff formats: link_to_patchs
This page was last modified on 10 October 2012, at 06:01.
44 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.