|
|
|
|
|
- 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
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. 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.
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. | | 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. Customizing the windows for automatic management of errors Functions for automatic management of errors The functions for automatic management of errors are as follows:
| | ErrorChangeParameter | Configures the automatic behavior that will be implemented if an error occurs in the current process. | ErrorInfo | Retrieves information about the last error that occurred in a function of a WINDEV, WINDEV Mobile or WEBDEV component. | ErrorPropagate | Propagates 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). | ErrorRestoreParameter | Restores the error process of a process. | ErrorThrow | Throw a non-fatal error. |
Related Examples:
|
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.
|
|
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.
|
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|