Namespace: Consultingwerk.Util
Class 
ErrorHelper Copy to Clipboard
Parent classes:
Inherits: Progress.Lang.Object

File:ErrorHelper
Purpose:Various support routines for structured error handling
Syntax:Static methods only, Protected constructor to disallow
instance creation
Author(s):Mike Fechner / Consultingwerk Ltd.
Created:Sat Jul 04 13:29:48 CEST 2009



Top Method Summary
Options Name Purpose
+ CHARACTER AddErrorMessage (character, character, character, character) Adds an ADM2 style formatted error message to an existing error message string
+ CHARACTER DatasetErrorStrings (handle) Returns a single CHARACTER string composed of the error-strings of all records (from all tables in the given Dataset instance)
+ DeRegisterErrorHandler (IErrorHandler) Deregisters the IErrorHandler implementation
+ CHARACTER ErrorTitle (Error) Returns the Title associated with an error message
+ CHARACTER ErrorTypeName (Error) Returns the Typename of the error object
+ CHARACTER FormattedErrorMessages (Error) Returns a single CHARACTER string composed of the messages Contained in the Progress.Lang.Error object
+ CHARACTER FormattedErrorMessagesExt (Error) Returns a single CHARACTER string composed of the messages Contained in the Progress.Lang.Error object, including the stack trace and the text of inner exceptions when present
+ CHARACTER GetRuntimeErrorMessage (integer) Returns the text of the given ABL error message
+ CHARACTER GetSmartMessage (character) Formats a SmartMessage
# LOGICAL HandleError (Error) Handles an Error object using the registered IErrorHandler implementations
+ LOGICAL HasMessageNumber (Error, integer) Returns if the error instance contains an error message with the given message number
+ Consultingwerk.Util.Error132Info ParseError132 (SysError) Parses an 132 runtime Error and returns the table and field/values (** Salesrep already exists with Sales Rep "bbb". (132))
+ RegisterErrorHandler (IErrorHandler) Registers a new IErrorHandler implementation
+ ResetErrorStatus () Resets the ERROR-STATUS:ERROR and ERROR-STATUS:NUM-MESSAGES etc.
+ ShowErrorMessage (Error) Display Error Message
+ ShowErrorMessage (Error, character) Display Error Message
+ ShowErrorMessage (Error, character, Form) Display Error Message
+ ShowErrorMessage (Error, Form) Display Error Message
+ ShowErrorMessageBox (Error) Display Error Message as an alert-box (to be used in functions and non-void methods due to WAIT-FOR limitations)
+ ShowErrorMessageBox (Error, character) Display Error Message as an alert-box (to be used in functions and non-void methods due to WAIT-FOR limitations)
+ LONGCHAR StackTrace (Error) Reformats the Error Stack Trace (most current code block first, not last as provided by the CallStack attribute

Top Constructor Summary
Options Name Purpose
# ErrorHelper () Protected default constructor.

Top Property Summary
Options Name Purpose
+ CHARACTER CurrentStacktrace Returns the current ABL stack trace
+ LOGICAL ErrorMessageDialogAllowed Allows to control if the ShowErrorMessage methods are allowed to show an error message using a GUI for .NET Form
+ CHARACTER ErrorMessageFormType The type name of the Form to be used as the ErrorMessageForm
+ LOGICAL SuppressTableAndFieldInfo Allows to control if Table And Field information should be suppressed with messages generated by the backend.


Method Detail
Top

PUBLIC CHARACTER AddErrorMessage (character, character, character, character)

Purpose: Adds an ADM2 style formatted error message to an existing error
message string
Notes:

Parameters:
pcMessage CHARACTER
The existing message text
pcText CHARACTER
The text of the additional message
pcField CHARACTER
The field that the message belongs to
pcTable CHARACTER
The table that the message belongs to
Returns CHARACTER
The resulting message text
Top

PUBLIC CHARACTER DatasetErrorStrings (handle)

Purpose: Returns a single CHARACTER string composed of the error-strings
of all records (from all tables in the given Dataset instance)
Notes: Method moved to DatasetHelper, kept here for backwards compability
as a facade to DatasetHelper:DatasetErrorStrings

Parameters:
phDataset HANDLE
The handle of the dataset to return the error strings from
Returns CHARACTER
The string composed of the error-strings of all records
Top

PUBLIC DeRegisterErrorHandler (IErrorHandler)

Purpose: Deregisters the IErrorHandler implementation
Notes:

Parameters:
poErrorHandler Consultingwerk.Framework.IErrorHandler
The IErrorHandler to deregister
Top

PUBLIC CHARACTER ErrorTitle (Error)

Purpose: Returns the Title associated with an error message
Notes: Errors that implemnt the IErrorTitle interface return their own title
For other errors, when the SmartFramework is present the type name is
used as the message key when looking up translations in the "Error"
translation scope.
When no title could be obtained, a default title is returned from this
routine

Parameters:
poError Progress.Lang.Error
The reference to the error object
Returns CHARACTER
The title associated with the error message
Top

PUBLIC CHARACTER ErrorTypeName (Error)

Purpose: Returns the Typename of the error object
Notes: Required as .NET Exceptions don't have an ABL Class
(GetClass() returns ?)

Parameters:
e Progress.Lang.Error
The Error (Progress error of .NET Exception) to return the type name for
Returns CHARACTER
The type name (class name) of the error object
Top

PUBLIC CHARACTER FormattedErrorMessages (Error)

Purpose: Returns a single CHARACTER string composed of the messages
Contained in the Progress.Lang.Error object
Notes:

Parameters:
poError Progress.Lang.Error
The Progress.Lang.Error to format
Returns CHARACTER
A string containing all formatted messages from the Error object
Top

PUBLIC CHARACTER FormattedErrorMessagesExt (Error)

Purpose: Returns a single CHARACTER string composed of the messages
Contained in the Progress.Lang.Error object, including the stack
trace and the text of inner exceptions when present
Notes: Useful when logging complex error objects to a file

Parameters:
poError Progress.Lang.Error
The Progress.Lang.Error to format
Returns CHARACTER
A string containing all formatted messages from the Error object
Top

PUBLIC CHARACTER GetRuntimeErrorMessage (integer)

Purpose: Returns the text of the given ABL error message
Notes: Parses the PROMSGS file

Parameters:
piMessageNumber INTEGER
The number of the error message to retrieve
Returns CHARACTER
The text of the error message
Top

PUBLIC CHARACTER GetSmartMessage (character)

Purpose: Formats a SmartMessage
Notes: This method is dependent on a Consultingwerk.SmartFramework.IMessageProvider
implementation registered in the ServiceContainer. When there is no
IMessageProvider implementation the vaue of pcSmartMessage will be
returned to the caller

Parameters:
pcSmartMessage CHARACTER
The smart message structure as returned by MessageFormatted class
Returns CHARACTER
The error message string as returned by the IMessageProvider
Top

PROTECTED LOGICAL HandleError (Error)

Purpose: Handles an Error object using the registered IErrorHandler
implementations
Notes: Logical return value indicates if the error has been completely
Handled, that is when this method returns TRUE, the ErrorHelper
will not display the error anymore, retrun false when the
ErrorHelper should still display the error message dialog.

Parameters:
poError Progress.Lang.Error
The Error object to handle
Returns LOGICAL
Logical value indicating of the error has been completely handled by an IErrorHandler instance
Top

PUBLIC LOGICAL HasMessageNumber (Error, integer)

Purpose: Returns if the error instance contains an error message with the given
message number
Notes: Returns FALSE also when poError = ?

Parameters:
poError Progress.Lang.Error
The error instance to verify
piMessageNumber INTEGER
The message number to search for
Returns LOGICAL
Logical value indicating if the error contains a message with the given message number
Top

PUBLIC Consultingwerk.Util.Error132Info ParseError132 (SysError)

Purpose: Parses an 132 runtime Error and returns the table and field/values
(** Salesrep already exists with Sales Rep "bbb". (132))
Notes:

Parameters:
poError Progress.Lang.SysError
The SysError to parse
Returns Consultingwerk.Util.Error132Info
The Error132Info with the details about the error
Top

PUBLIC RegisterErrorHandler (IErrorHandler)

Purpose: Registers a new IErrorHandler implementation
Notes:

Parameters:
poErrorHandler Consultingwerk.Framework.IErrorHandler
The reference to the IErrorHandler to register
Top

PUBLIC ResetErrorStatus ()

Purpose: Resets the ERROR-STATUS:ERROR and ERROR-STATUS:NUM-MESSAGES etc.
Notes: Useful to wipe pending error stati and messages after executing ABL
code with NO-ERROR

Top

PUBLIC ShowErrorMessage (Error)

Purpose: Display Error Message
Notes: Error Type (Class) will be used a default title

Parameters:
err Progress.Lang.Error
The Error object to visualize
Top

PUBLIC ShowErrorMessage (Error, character)

Purpose: Display Error Message
Notes: Stacktrack will be displayed when FrameworkSettings:DebugMode = TRUE

Parameters:
e Progress.Lang.Error
The Error object to visualize
pcTitle CHARACTER
The title for the message message (dialog)
Top

PUBLIC ShowErrorMessage (Error, character, Form)

Purpose: Display Error Message
Notes: Stacktrack will be displayed when FrameworkSettings:DebugMode = TRUE

Parameters:
e Progress.Lang.Error
The Error object to visualize
pcTitle CHARACTER
The title for the message message (dialog)
poParentForm System.Windows.Forms.Form
The ParentForm
Top

PUBLIC ShowErrorMessage (Error, Form)

Purpose: Display Error Message
Notes: Stacktrack will be displayed when FrameworkSettings:DebugMode = TRUE

Parameters:
e Progress.Lang.Error
The Error object to visualize
poParentForm System.Windows.Forms.Form
The ParentForm
Top

PUBLIC ShowErrorMessageBox (Error)

Purpose: Display Error Message as an alert-box (to be used in functions
and non-void methods due to WAIT-FOR limitations)
Notes: Error Type (Class) will be used a default title

Parameters:
e Progress.Lang.Error
The Error object to visualize
Top

PUBLIC ShowErrorMessageBox (Error, character)

Purpose: Display Error Message as an alert-box (to be used in functions
and non-void methods due to WAIT-FOR limitations)
Notes: Stacktrack will be displayed when FrameworkSettings:DebugMode = TRUE

Parameters:
e Progress.Lang.Error
The Error object to visualize
pcTitle CHARACTER
The title for the message message (dialog)
Top

PUBLIC LONGCHAR StackTrace (Error)

Purpose: Reformats the Error Stack Trace (most current code block first,
not last as provided by the CallStack attribute
Notes:

Parameters:
e Progress.Lang.Error
The error object to return the formatted stacktrace for
Returns LONGCHAR
The formatted stack trace


Constructor Detail
Top

PROTECTED ErrorHelper ()

Purpose: Protected default constructor.
Notes: There's no need to create instances of the helper classes



Property Detail
Top

PUBLIC CHARACTER CurrentStacktrace

Purpose: Returns the current ABL stack trace
Notes: Throws an AppError to receive the stack trace, works also when
SESSION:ERROR-STATUS-TRACE ERROR-STATUS-TRACE is generally set to FALSE

Returns CHARACTER
The current ABL Stacktrace
Top

PUBLIC LOGICAL ErrorMessageDialogAllowed

Purpose: Allows to control if the ShowErrorMessage methods are allowed
to show an error message using a GUI for .NET Form
Notes: When set to FALSE the message is delegated to the ShowErrorMessageBox
methods

Returns LOGICAL
Top

PUBLIC CHARACTER ErrorMessageFormType

Purpose: The type name of the Form to be used as the ErrorMessageForm
Notes: The type needs to implement the
Consultingwerk.Util.Forms.IErrorMessageForm interface

Returns CHARACTER
Top

PUBLIC LOGICAL SuppressTableAndFieldInfo

Purpose: Allows to control if Table And Field information should be suppressed
with messages generated by the backend.
Notes:

Returns LOGICAL


©2006-2016 Consultingwerk Ltd.         info@consultingwerk.de         http://www.consultingwerk.de       26.08.2016 08:46:25