ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

New WEBDEV 28 feature!
Help / WEBDEV Tutorial / Part 09 - Useful WEBDEV features
  • In this lesson you will learn the following concepts
  • Overview
  • Operating mode
  • Implementation
  • Types of errors
  • Automatic error handling: a training example
Lesson 9.2. Automatic error handling
In this lesson you will learn the following concepts
  • What is automatic error handling?
  • Configuring the automatic error handling.
Lesson duration

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

Operating mode

Two operations are performed when a WLanguage function detects an error:
  • the function returns an error value (e.g., fOpen returns "-1" if the specified file could not be opened).
  • WLanguage detects the error (the ErrorOccurred variable is set to True) and the details of the error can be retrieved with ErrorInfo.
The second operation can be done automatically by the WEBDEV error management assistant.

Implementation

The automatic error handling can be configured:
  • in the code editor: click the link "If error: By program" in the code editor:
    Automatic error handling (code editor)
  • programmatically with the ErrorChangeParameter function.

Types of errors

Two types of errors can occur in WLanguage:
  • "non-fatal" errors (also called runtime errors): in most cases, these errors are handled in the code and do not stop the application. For example, opening a file that cannot be accessed or an archive that does not exist.
  • "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, etc.). 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 error handling mechanism handles these two types of errors using different methods to set behaviors adapted to the errors encountered.
Automatic error handling: a training example
  • To understand the different error cases and how they are managed, we will use an example provided with WEBDEV.
    1. Go to the WEBDEV home page (Ctrl + <).
    2. On the home page, click "Open an example". The list of complete examples and training examples provided with WEBDEV is displayed.
    3. Type "Error" in the search area. Only the examples containing this word are listed.
      Search for an example
    4. Select the "WW_Auto_Error_Management" project. The project is loaded.
  • This project presents:
    • how to handle a non-fatal error (opening a non-existent archive).
    • how to handle a fatal error (dividing an integer by 0).
    • how to handle an error on multiple levels.
  • Test the project (click Test project in the quick access buttons).
    1. Click "Fatal error".
    2. The following page is displayed. This page is used the test the error when an integer is divided by 0.
      Test of a fatal error
    3. Click "Test error handling".
    4. When running the line of code that triggers the error, a procedure is automatically called. This procedure displays the error message and stops the current process.
    5. Click "OK".
  • Click "Non-fatal error".
    1. The following page is displayed.
      Test of a non-fatal error
    2. Click "Test error handling".
    3. When running the line of code that triggers the error, an error message is displayed.
    4. Validate the error message.
  • Click "Error on multiple levels".
    1. The following page is displayed. This page is used to test an error on multiple levels (process calling a procedure that opens an archive that does not exist).
      Test of an error on multiple levels
    2. Click "Test error handling".
    3. When running the line of code 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 handles HFSQL errors automatically. For more details, see Assisted HFSQL error handling.
Previous LessonTable of contentsNext Lesson
Minimum version required
  • Version 28
Comments
Click [Add] to post a comment

Last update: 12/02/2022

Send a report | Local help