ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Exception functions
  • Overview
  • Automatic error handling
  • Implementing the automatic error handling
  • Run the error process ("CASE ERROR:" in the code)
  • Running a procedure for processing the error
  • Show error and exit application
  • Show error and resume input in the current window
  • Display the error and let the user decide
  • Exit the procedure, return XXX and show the error
  • Customizing the windows for automatic management of errors
  • Functions for automatic management of errors
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Automatic error handling
Overview
Error handling can be customized for each process.
No more "IF ... NOT", "IF ErrorOccurred ..." and other nested tests that made the code difficult to understand.
You can choose to use automated error processing or advanced management via the different WLanguage functions.
Important: The automatic management of errors and exceptions operates for the process for which it was defined.
Automatic error handling

Implementing the automatic error handling

To implement the automatic error handling:
  1. In the code editor, open the event or process in which the errors will be handled: initialization code, click code, procedure, etc.
  2. In the code header, clck "If Error: by program".
  3. The window that is displayed allows you to specify the type of automatic process to perform:
Remarks:
  • The code for managing the error found in the current process has priority over the automatic processes in the following cases:
    • Test of a function such as "IF NOT xxxx=True or False"
    • Test of errors with the ErrorOccurred variable.
      Java The management code of the error found in the current process does not have priority over the automatic processes: the error process of the code AND the automatic process will be run in any case.
  • ErrorChangeParameter can be used for advanced error management.

Run the error process ("CASE ERROR:" in the code)

If this option is selected, a line of code is added to the current code "CASE ERROR: ". The lines of code following this statement will be run when an error occurs in the previous lines of code. This option is recommended to group all the error processes that may occur.
Remark: If "ERROR CASE" is written directly in the code, the option "Run the error process ("CASE ERROR:" in the code)" will be automatically selected.

Running a procedure for processing the error

If this option is selected, the specified procedure will be automatically run to process the error when an error occurs in the current process. This option is recommended if a procedure used to process the errors is already found in your application. This procedure will be automatically called when an error occurs. No test to run.
This procedure can return one of the constants found in the table below.
Depending on the constant returned, WINDEV, WEBDEV or WINDEV Mobile will perform the corresponding process.
opCancelThe function that triggered the error returns an error and the code continues to run.
opEndProcessThe function that triggered the error returns an error and the current process stops. Equivalent to the following line of code:
IF NOT <HFSQL function> THEN SetFocusAndReturnToUserInput()
opEndProgramThe function that triggered the error returns an error and the program stops. Equivalent to the following line of code:
IF NOT <Function> THEN EndProgram()
opRelaunchProgramEnds the application and automatically restarts the application.
Java This constant is not available.
opRetryThe function that triggered the error is re-run.
Java This constant is not available in Java.

Show error and exit application

If this option is selected, the following window will be automatically displayed if an error occurs in the application:
This window allows the user to:
  • Copy the error details to the clipboard (to transmit these details to the application provider for example)
  • Stop the application
  • Automatically restart the application once it has been stopped. This option is not available in Java.
WINDEV Remark: if the "Feedback" component is included in the application (directly or via the "?" menu), the error report can be sent to the application provider.

Show error and resume input in the current window

If this option is selected, the following window will be automatically displayed if an error occurs in the application:
This window allows the user to:
  • Copy the error details to the clipboard (to transmit these details to the application provider for example)
  • Stop the application
  • Cancel the operation: the current process is canceled. The current window of the application is displayed.
  • Automatically restart the application once it has been stopped.
WINDEV Remark: if the "Feedback" component is included in the application (directly or via the "?" menu), the error report can be sent to the application provider.

Display the error and let the user decide

If this option is selected, the following window will be automatically displayed if an error occurs in the application:
This window allows the user to:
  • Copy the error details to the clipboard (to transmit these details to the application provider for example)
  • Stop the application
  • Cancel the operation: the current process is canceled. The current window of the application is displayed.
  • Retry the operation: the operation that triggered the error will be canceled then re-run.
  • Automatically restart the application once it has been stopped. This option is not available in Java.
WINDEV Remark: if the "Feedback" component is included in the application (directly or via the "?" menu), the error report can be sent to the application provider.
Java This option and "Display the error and resume the input in the current window" have the same operating mode.

Exit the procedure, return XXX and show the error

If this option is selected, RESULT XXX will be automatically performed when an error occurs in the code.
The following values can be returned:
  • -1
  • 0
  • Empty string ("")
  • FALSE
  • NULL
  • TRUE
The error can also be displayed.
Customizing the windows for automatic management of errors
WINDEV By default, the windows for managing the errors, the exceptions and the assertions are included in the application. These windows are available in English and in French.
To customize these windows (or to translate them), all you have to do is import the corresponding windows into your project:
  1. On the "Project" tab, in the "Project" group, expand "Import" and select "WINDEV elements and their dependencies".
  2. Select the directory of the elements to import: "Programs\Data\Preset Windows\EN\Assert - Error - Exception".
  3. Select the windows to import:
    WINDEVType of window
    WD_DisplayAssert.wdwWindow for managing the assertions
    WD_DisplayError.wdwWindow for managing the errors
    WD_DisplayException.wdwWindows for managing the exceptions
    WD_ErrorTemplate.wdtTemplate used by the WINDEV windows.
  4. Validate. The windows are included in your project. These windows will be automatically used and they will replace the default windows.
Remark: To use the default windows, all you have to do is delete the imported windows from your project.
Functions for automatic management of errors
The functions for automatic management of errors are as follows:
ErrorChangeParameterConfigures the automatic behavior that will be implemented if an error occurs in the current process.
ErrorInfoRetrieves information about the last error that occurred in a function of a WINDEV, WINDEV Mobile or WEBDEV component.
ErrorPropagatePropagates a non-fatal error that can be processed by the calling code if the management of non-fatal errors was enabled for this code (in the code editor or by ErrorChangeParameter).
ErrorRestoreParameterRestores the error process of a process.
ErrorThrowThrow a non-fatal error.
Related Examples:
WD Auto Error Management Training (WINDEV): WD Auto Error Management
[ + ] The "WD Automatic Management of Errors" example is an educational example about the automatic management of errors.
This example presents the fatal and non-fatal errors on several levels.
WD Managing the Java errors Training (WINDEV): WD Managing the Java errors
[ + ] WINDEV enables you to develop Java applications without even knowing Java.
You benefit from the power and from the automated processes of the WINDEV environment.
One of the most useful automated processes is the automatic management of errors.
This example presents the operating mode and the implementation of the mechanism for managing the WINDEV errors.
Some illustrations allow you to understand the simplification performed when implementing this feature.
This project is configured to generate a Java archive.
Minimum version required
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/08/2024

Send a report | Local help