Exception handling in WRT
Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic, Nokia 6220 clasic
Compatibility
Platform(s): S60 5th Edition, S60 3rd Edition, FP2
Article
Keywords: widget.setNavigationEnabled(), alert
Created: ivruban
(29 Jan 2009)
Last edited: hamishwillee
(10 Oct 2012)
Contents |
Overview
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.
widget.setNavigationEnabled(false);
} catch(exception) {
document.getElementById("result").value = exception;
}
}
function riseException() {
try{
alert(somevar);
} catch (exception){
document.getElementById("result").innerHTML = exception;
}
}
Postconditions
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: Media:ExceptionHandlingWRT.zip.
- 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


(no comments yet)