Search these areas:
Support Forums
Product Info

DataWeb: What's New
Creating an Application
The DataWeb Designer
Application Management
Data Tables
Data Tables
Data Analysis
-JavaScript Language Reference
-The HotRAD Source Editor
-Working with Data Classes
-Building DataWeb Script Classes
-JavaScript Language Enhancements
-Handling Exceptions
-JavaScript Reserved Words
Object Model
Full-Text Search
Domain and Email Hosting
HotBlock Modules
Account Management
New Responsive UI Module

DataWeb Help
Support Forums
Script Library
Knowledge Base

Home > Support

DataWeb User's Guide

Handling Exceptions
Many scripting calls throw exceptions when a runtime error occurs. As the programmer, you should check for exceptions in code and handle them before a runtime error is displayed to the user, either by resolving the condition that caused the error and continuing program execution, or by ending execution gracefully.

To handle an exception, place the code that may throw an exception in a try block, followed by a catch block. If an exception is thrown within a try block, execution is immediately redirected to the catch block, where you can put code to correct the error or end execution. If an exception occurs and there is no try block, a runtime error occurs, halting execution.

When an exception is thrown, an object of type Error is passed to the catch block. The Exception object has two properties: the object property, which indicates what type of object threw the exception, and the description property, which returns a string describing the cause of the exception. You can use this object to get information about the exception.

In addition to the try and catch blocks, your exception handling code can include an optional finally block. The code in the finally block will always be executed, whether or not an exception was thrown. If an exception occurs, the code in the finally block will be executed after the code in the catch block.

The following example demonstrates a simple exception handler:
  var rs ="MyTable", "*");
  Script.Log("Database Exception:", "Thrown by: "
  + e.object + ", Description: " + e.description);
  Script.Log("Exiting now.");
Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
DataWeb, 720 North 10th Street, A #145, Renton, Washington 98057 *425-583-5970* Fax 484-770-4706* Email Us