PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • 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
  • Display error and exit application
  • Display 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.
  • 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.
AndroidAndroid Widget This constant is not available.
opRetryThe function that triggered the error is re-run.

Display 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 into 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.

Display 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 into 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.

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 into 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.
Android 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
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.
ErrorThrowThrow a non-fatal error.
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.
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