PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Automatic management of errors
  • Implementing the automatic management of errors
  • Running the error process ("CASE ERROR" in the code)
  • Running a procedure for processing the error:
  • Displaying the error and exiting from the application:
  • Display the error and resume the input in the current window
  • Displaying the error and giving the decision to the user:
  • Returning the XXX value and displaying 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/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Automatic management of errors
Overview
The management of errors can be customized by 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 management of errors
WINDEVWEBDEV - Server codeReports and QueriesAndroidiPhone/iPadWindows MobileUniversal Windows 10 AppJava

Implementing the automatic management of errors

To implement the automatic management of errors:
  1. In the code editor, display the process where the errors must be managed: initialization code, click code, procedure, ...
  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:
Notes:
  • 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.
  • The advanced management of errors can be implemented by ErrorChangeParameter.
WINDEVWEBDEV - Server codeReports and QueriesAndroidiPhone/iPadWindows MobileJava

Running the error process ("CASE ERROR" in the code)

If this option is selected, a code line is added to the current code "CASE ERROR: ". The code lines following this statement will be run when an error occurs in the previous code lines. This option is recommended to group all the error processes that may occur.
WINDEVWEBDEV - Server codeReports and QueriesAndroidiPhone/iPadWindows MobileJava

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.
opRetryThe function that triggered the error is re-run.
Java This constant is not available in Java.
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 code line:
IF NOT <HFSQL function> THEN ReturnToCapture()
opEndProgramThe function that triggered the error returns an error and the program stops. Equivalent to the following code line:
IF NOT <Function> THEN EndProgram()
opRelaunchProgramEnds the application and automatically restarts the application.
AndroidJava This constant is not available.
WINDEVReports and QueriesAndroidiPhone/iPadWindows MobileJava

Displaying the error and exiting from the 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.
WINDEV Note: if the "Feedback" component is included in the application (directly or via the "?" menu), the error report can be sent to the application provider.
WINDEVReports and QueriesAndroidiPhone/iPadWindows MobileJava

Display the error and resume the 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.
WINDEV Note: if the "Feedback" component is included in the application (directly or via the "?" menu), the error report can be sent to the application provider.
WINDEVReports and QueriesiPhone/iPadWindows Mobile

Displaying the error and giving the decision to the user:

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.
WINDEV Note: if the "Feedback" component is included in the application (directly or via the "?" menu), the error report can be sent to the application provider.
AndroidJava This option and "Display the error and resume the input in the current window" have the same operating mode.
WINDEVWEBDEV - Server codeReports and QueriesAndroidiPhone/iPadWindows MobileJava

Returning the XXX value and displaying 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
WINDEVWindows Mobile 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. Select:
    • WINDEV "File .. Import .. WINDEV elements and their dependencies" WINDEV On the "Project" pane, in the "Project" group, expand "Import" and select "WINDEV elements and their dependencies"
    • WINDEV Mobile "File .. Import .. WINDEV Mobile elements and their dependencies" WINDEV Mobile On the "Project" pane, in the "Project" group, expand "Import" and select "WINDEV Mobile elements and their dependencies"
  2. Select the directory of the elements to import: "Programs\Data\Preset windows\Assertion - Error - Exception".
  3. Select the windows to import:
    WINDEVWINDEV MobileType of window
    WD_DisplayAssert.wdwWM_DisplayAssert.WPWWindow for managing the assertions
    WD_DisplayError.wdwWM_DisplayError.WPWWindow for managing the errors
    WD_DisplayException.wdwWM_DisplayException.WPWWindows 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.
Note: 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:
Versions 10 and later
ErrorChangeParameter
New in version 10
ErrorChangeParameter
ErrorChangeParameter
Configures the automatic behavior that will be implemented if an error occurs in the current process.
Versions 09 and later
ErrorInfo
New in version 09
ErrorInfo
ErrorInfo
Retrieves information about the last error that occurred in a function of a WINDEV, WINDEV Mobile or WEBDEV component.
Versions 10 and later
ErrorPropagate
New in version 10
ErrorPropagate
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).
Versions 10 and later
ErrorRestoreParameter
New in version 10
ErrorRestoreParameter
ErrorRestoreParameter
Restores the error process of a process.
Versions 10 and later
ErrorThrow
New in version 10
ErrorThrow
ErrorThrow
Triggers 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 required version
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment