PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
New WEBDEV 24 feature!
  • This lesson will teach you the following concepts
  • Overview
  • Operating mode
  • Implementation
  • Types of affected errors
  • Automatic management of errors: a training example
Lesson 9.2. Automatic management of errors
This lesson will teach you the following concepts
  • What is the automatic management of errors?
  • Using the automatic management of errors.

Estimated time: 10 mn
Previous LessonTable of contentsNext Lesson
Overview
WEBDEV can manage the errors automatically. This feature helps you reduce the number of code lines while centralizing the management of errors. The use of this feature also makes the code easier to read.

Operating mode

Two operations are performed when an error is detected by a WLanguage function:
  • an error value is returned by the function (for example, fOpen returns "-1" if the specified file was not opened).
  • the error is detected by WLanguage (the ErrorOccurred variable is set to True) and the error details are returned by ErrorInfo.
This second operation can be automatically managed by the error management of WEBDEV.

Implementation

The automatic management of errors can be configured:
  • in the code editor: all you have to do is click the link "If error: By program" in the code editor:
  • by programming with ErrorChangeParameter.

Types of affected errors

Two types of errors can occur in WLanguage:
  • the "non-fatal" errors (also called runtime errors): in most cases, these errors are managed in the code and they do not stop the application. For example, opening a file that cannot be accessed or an archive that does not exist.
  • the "fatal" errors (also called programming errors): in most cases, these errors are linked to a development problem (access to a non-declared file, use of non-existing controls ...). A "fatal" error can also occur after a "non-fatal" error that was not processed properly. In this case, the application will be stopped.
The mechanism for managing errors is used to manage these two types of errors according to different methods in order to specify behaviors adapted to the errors that occur.
Automatic management of errors: a training example
  • To understand the different error cases as well as their management, we will be using a training example supplied with WEBDEV.
    1. Display the WEBDEV home page (Ctrl + <).
    2. On the home page, click "Open an example". The list of complete examples and training examples supplied with WEBDEV is displayed.
    3. Type "Error" in the search area. Only the examples containing this word are listed.
    4. Select the "WW_Auto_Error_Management" project. The project is loaded.
  • This project presents:
    • the management of a non-fatal error (opening a non-existent archive).
    • the management of a fatal error (dividing an integer by 0).
    • the management of an error on various levels.
  • Run the project test by clicking (among the quick access buttons).
    1. Click "Non-fatal error".
    2. The following page is displayed.
    3. Click the "Test this error management" button.
    4. When running the code line that triggers the error, an error message is displayed.
    5. Validate the error message.
  • Click "Fatal error".
    1. The following page is displayed. This page is used the test the error when an integer is divided by 0.
    2. Click the "Test this error management" button.
    3. When running the code line that triggers the error, a procedure is automatically called. This procedure is used to display the error message and to stop the current process.
    4. Click "OK".
  • Click "Error on several levels".
    1. The following page is displayed. This page is used to test an error on several levels (process calling a procedure that opens an archive that does not exist).
    2. Click the "Test this error management" button.
    3. When running the code line that triggers the error:
      • the procedure returns "False" to the calling process.
      • the calling process displays an error message and stops the process.
    4. Validate the error message.
  • Close the browser to end the test.

Example

WEBDEV also proposes an automatic management of HFSQL errors. See Assisted management of HFSQL errors for more details.
Previous LessonTable of contentsNext Lesson
Minimum version required
  • Version 24
Comments
Click [Add] to post a comment