Implementing the automatic error handling
To implement the automatic error handling:
- In the code editor, open the event or process in which the errors will be handled: initialization code, click code, procedure, etc.
- In the code header, clck "If Error: by program".
- 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.
| |
opCancel | The function that triggered the error returns an error and the code continues to run. |
opEndProcess | The 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() |
opEndProgram | The function that triggered the error returns an error and the program stops. Equivalent to the following line of code: IF NOT <Function> THEN EndProgram() |
opRelaunchProgram | Ends the application and automatically restarts the application.
|
opRetry | The function that triggered the error is re-run. |
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.
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.
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.
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.