public class ErrorManager
extends java.lang.Object
ERROR-STATUS
and NO-ERROR
Progress features.
The following is the mapping of Progress features to Java:
Progress Feature Type Java Feature --------------------------- ------------ ---------------------------- error-status:error attributeisError()
error-status:num-messages attributenumErrors()
error-status:get-message methodgetErrorText(com.goldencode.p2j.util.integer)
error-status:get-number methodgetErrorNumber(com.goldencode.p2j.util.integer)
In order to properly use this class, all processing which must be handled
on a NO-ERROR
basis must be run as delegated code block processed by
silent(java.lang.Runnable)
. This code catches any error exception so that the business logic
aborts at the point of the error but the exception does not reach the block level.
All called code that honors NO-ERROR
must be aware of silent error
mode. This can be done via the following methods (in a library):
recordOrThrowError(int, java.lang.String)
. After
calling this method, return silently from the library.
isSilentError()
to determine if the silent mode is
enabled.
addError(int, java.lang.String, boolean)
to add an error to the list if silent
mode is enabled.
ErrorConditionException
.
ErrorUnwindException
to unwind the
stack to the point in the library where a silent return is
possible. This exception must be caught in the library code
and will not be caught in the client application. Use of
this exception should be completely hidden from the client
application.
On the server, the silent error mode flag is saved at every top level
scope (see TransactionManager.pushScope(java.lang.String, int, boolean, boolean, boolean, boolean)
) and it is restored at
the end of that scope (see TransactionManager.popScope()
).
This is done so that "nested" NO-ERROR conditions (e.g. during a RUN
statement on an internal or external procedure or an assignment statement
with a call to a user defined function) are maintained properly. In
particular, the called procedure or function does NOT execute as if in
silent mode unless the code there is so bracketed. However, the one
exception to this is that the RETURN ERROR behavior implemented by the
TransactionManager
is aware of whether or not silent error
mode was enabled in the caller.
It must be noted that Progress seems to provide a single global instance of ERROR-STATUS handle and all its data. Thus this data can be seen across call/return boundaries and is only modified at very specific points. for example, the error flag is only changed at the end of a NO-ERROR statement. Likewise, the previous list of errors can be read until the first error occurs after a NO-ERROR statement starts. This deferred clearing of the error list is implemented using the pending error flag. When that flag is set, the error list is cleared. If no errors occur in the NO-ERROR statement then the error list is cleared at the same time the error flag is cleared at the end of the NO-ERROR statement.
Modifier and Type | Class and Description |
---|---|
private static class |
ErrorManager.ContextContainer
Simple container that stores and returns a context-local instance of
the global work area.
|
private static class |
ErrorManager.ErrorDataAccess
Provides access to the error data when running on the server.
|
static class |
ErrorManager.ErrorEntry
Stores the data related to a single error.
|
private static class |
ErrorManager.ErrorStatus
This class corresponds ERROR-STATUS p2j handle, that can contain supressed errors
information in case of NO-ERROR expression used in P4GL statement.
|
private static class |
ErrorManager.LocalDataAccess
Error storage local to client-side.
|
private static class |
ErrorManager.ServerDataAccess
Provides access to the error data when running on the server.
|
private static class |
ErrorManager.WorkArea
Stores global data relating to the state of the current context's
transactions.
|
Modifier and Type | Field and Description |
---|---|
private static RemoteErrorData |
da
Error data access interface between client and server.
|
private static int |
ERR_CONDITIONS_CAPACITY
Capacity of error conditions stack for _MSG function
|
private static ErrorWriter |
errorWriter
Error writer object instance for client.
|
private static boolean |
headless
Headless mode
|
private static RemoteErrorData |
local
Error data access to local storage.
|
private static java.util.logging.Logger |
LOG
Logger (safe as a JVM-wide value rather than as context-local).
|
private static boolean |
serverSide
Does this instance belong to the server side part.
|
private static ErrorManager.ContextContainer |
work
Stores context-local state variables.
|
Constructor and Description |
---|
ErrorManager() |
Modifier and Type | Method and Description |
---|---|
static void |
addError(int num,
java.lang.String text,
boolean errFlag)
Adds an error entry to the error list.
|
static void |
addError(int num,
java.lang.String text,
boolean errFlag,
boolean prefix)
Adds an error entry to the error list.
|
(package private) static void |
addRaisedCondition(int[] errNums)
Adds error numbers to raised error numbers stack (for _MSG function).
|
static void |
addRecord(java.lang.Object record)
Adds a record to the list of error records.
|
static handle |
asHandle()
Get a the instance for the ERROR-STATUS system handle.
|
static java.lang.String |
buildAbendText(int num,
java.lang.String text)
Manufactures Progress compatible formatted abend error text based on the
given error data.
|
static java.lang.String |
buildErrorText(int num,
java.lang.String text)
Manufactures Progress compatible formatted error text based on the
given error data.
|
static java.lang.String |
buildErrorText(int num,
java.lang.String text,
boolean prefix)
Manufactures Progress compatible formatted error text based on the
given error data.
|
static java.lang.String |
buildErrorText(int num,
java.lang.String text,
boolean prefix,
boolean addDot)
Manufactures Progress compatible formatted error text based on the
given error data.
|
static void |
clearPending()
Clears pending error status.
|
private static java.util.List<ErrorManager.ErrorEntry> |
compileErrorEntries(java.lang.Throwable error)
Extract from
error and any chained root cause exceptions
of type NumberedException
error messages and numbers with which to compile a list of error
entries. |
static void |
conditionalShowErrorAndAbend(int num,
java.lang.String text)
Manufacture error text based on the given parameters; after displaying the error text on
the client, the application is stopping.
|
static void |
displayAbend(int num,
java.lang.String msg)
Format the text of the abend message and then display that text on
on the terminal.
|
static void |
displayError(int num,
java.lang.String msg)
Format the text of the error message and then display that text on
on the terminal.
|
static void |
displayError(int num,
java.lang.String msg,
boolean prefix)
Format the text of the error message and then display that text on
on the terminal.
|
static void |
displayError(java.lang.String errmsg)
Display the given error message on the terminal.
|
static void |
displayError(java.lang.String errmsg,
boolean noMessageBox)
Display the given error message on the terminal.
|
static void |
displayErrorRedirected(int num,
java.lang.String msg,
boolean prefix)
Format the text of the error message and then display that text on the terminal.
|
static void |
displayErrorRedirected(java.lang.String msg)
Format the text of the error message and then display that text on the terminal.
|
static void |
displayWarning(int num,
java.lang.String msg)
Format the text of the warning message and then display that text on
on the terminal.
|
static void |
displayWarning(int num,
java.lang.String msg,
boolean prefix)
Format the text of the warning message and then display that text on
on the terminal.
|
static void |
displayWarning(java.lang.String wrnmsg)
Display the given warning message on the terminal.
|
(package private) static java.util.Iterator<java.lang.String> |
errorTexts(int num,
java.lang.String text,
java.lang.Throwable error)
Get an iterator on Progress-style error text strings, derived from the
error information stored in
error (including its possible
chain of root causes), and from the given error number and text. |
private static java.util.Iterator<java.lang.String> |
errorTexts(java.util.List<ErrorManager.ErrorEntry> entries)
Get an iterator on Progress-style error text strings, based upon the
ErrorEntry objects stored in a list. |
(package private) static java.util.Iterator<java.lang.String> |
errorTexts(java.lang.Throwable error)
Get an iterator on Progress-style error text strings, derived from the
error information stored in
error (including its possible
chain of root causes). |
static void |
forwardPending()
Makes pending error status current.
|
static integer |
getErrorNumber(int index)
Returns the Progress compatible error number associated with the error
entry at the given index in the error list.
|
static integer |
getErrorNumber(integer index)
Returns the Progress compatible error number associated with the error
entry at the given index in the error list.
|
static integer |
getErrorNumberAtIndex(int64 index)
Java implementation for the _msg() function.
|
static integer |
getErrorNumberAtIndex(integer index)
Java implementation for the _msg() function.
|
static integer |
getErrorNumberAtIndex(long index)
Java implementation for the _msg() function.
|
static handle |
getErrorObjectDetail()
Returns a handle for the ERROR-OBJECT-DETAIL attribute, set in cases of SOAP-related faults.
|
static character |
getErrorText(int index)
Returns the Progress compatible error text associated with the error
entry at the given index in the error list.
|
static character |
getErrorText(integer index)
Returns the Progress compatible error text associated with the error
entry at the given index in the error list.
|
static RemoteErrorData |
getLocalAccess()
Get the
RemoteErrorData implementation which uses local storage. |
static java.util.LinkedList<java.lang.Integer> |
getRaisedConditions()
Gets err nums for raised errors.
|
static java.lang.Object |
getRecord(int index)
Gets a record from the list of error records.
|
static character |
getResourceType()
Get the type of its associated handle.
|
static int |
getSize()
Gets the size of the list of error records.
|
static java.lang.Long |
id()
Get this resource's ID.
|
static void |
id(long id)
Set this resource's ID.
|
static void |
initClient(RemoteErrorData errorServer)
Initializes the proper error data access on the client.
|
static void |
initErrorWriter(ErrorWriter errorWriterInitial)
Initializes the proper error writer on the client.
|
static logical |
isError()
Returns the state of the error flag which was set during the last silent mode processing,
even if silent error mode is not currently active.
|
static boolean |
isErrorFlag()
Queries the state of
error variable. |
static boolean |
isHeadless()
Determines if headless mode should be supported.
|
static boolean |
isIgnore()
Queries the state of
ignore variable. |
static boolean |
isInBatchMode()
Checks if the client is running in batch mode.
|
static boolean |
isInCanFindBracket()
Check whether this context is in a CAN-FIND bracket.
|
static boolean |
isPending()
Queries the state of
pendingError variable. |
static boolean |
isPendingError()
Returns the state of the current error flag which denotes if any error has occurred
while silent mode is active.
|
static boolean |
isSilent()
Queries the state of
silent variable. |
static boolean |
isSilentError()
Reports if silent error mode has been enabled.
|
static boolean |
isSuppressWarnings()
Reflects the value of SESSION:SUPPRESS-WARNINGS attribute.
|
static boolean |
isSystemAlertBoxes()
Get the state of SESSION:SYSTEM-ALERT-BOXES attribute.
|
static boolean |
isWarningMode()
Reports if warning mode has been enabled.
|
private static void |
log(java.lang.String message,
boolean silent)
Write a formatted log entry with the error text.
|
private static void |
log(java.lang.String message,
java.lang.Throwable trw,
boolean silent)
Write a formatted log entry with the error text.
|
static void |
noRecordOrThrowError(java.lang.String msg)
|
static integer |
numErrors()
Returns the number of the errors (recorded in the error list) which have occurred during
the last usage of silent error mode.
|
private static void |
postprocessOnAbend(java.lang.String errmsg)
Perform postprocessing for
showErrorAndAbend(int, String) . |
private static void |
postprocessOnAbend(java.lang.String[] text)
Perform postprocessing for
showErrorAndAbend(int[], String[]) . |
static void |
readOnlyError(java.lang.String attribute)
API needed to implement read-only attribute assignment (a 4GL
"feature").
|
static void |
recordOrShowError(int[] num,
java.lang.String[] text,
boolean modal)
Manufacture error text based on the given parameters, if silent error mode is enabled,
then this error number and the generated error text will be stored in the error list,
otherwise this generated error text will be used to display modal or modeless box in
the UI.
|
static void |
recordOrShowError(int[] num,
java.lang.String[] text,
boolean modal,
boolean prefix)
Manufacture error text based on the given parameters, if silent error mode is enabled,
then this error number and the generated error text will be stored in the error list,
otherwise this generated error text will be used to display modal or modeless box in
the UI.
|
static void |
recordOrShowError(int[] num,
java.lang.String[] text,
boolean modal,
boolean prefix,
boolean isError)
Manufacture one or more error texts based on the given parameters, if silent error mode is
enabled, then these error numbers and the respective generated error text messages will be
stored in the error list, otherwise this generated error texts will be used to display
modal or modeless box in the UI.
|
static void |
recordOrShowError(int[] num,
java.lang.String[] text,
boolean modal,
boolean prefix,
boolean isError,
boolean asMsg)
Manufacture one or more error texts based on the given parameters, if silent error mode is
enabled, then these error numbers and the respective generated error text messages will be
stored in the error list, otherwise this generated error texts will be used to display
modal or modeless box in the UI.
|
static void |
recordOrShowError(int[] num,
java.lang.String[] text,
boolean modal,
boolean prefix,
boolean isError,
boolean asMsg,
boolean addDot)
Manufacture one or more error texts based on the given parameters, if silent error mode is
enabled, then these error numbers and the respective generated error text messages will be
stored in the error list, otherwise this generated error texts will be used to display
modal or modeless box in the UI.
|
static void |
recordOrShowError(int num,
java.lang.String text,
boolean modal)
Manufacture error text based on the given parameters, if silent error mode is enabled,
then this error number and the generated error text will be stored in the error list,
otherwise this generated error text will be used to display modal or modeless box in
the UI.
|
static void |
recordOrShowError(int num,
java.lang.String text,
boolean modal,
boolean prefix)
Manufacture error text based on the given parameters, if silent error mode is enabled,
then this error number and the generated error text will be stored in the error list,
otherwise this generated error text will be used to display modal or modeless box in
the UI.
|
static void |
recordOrShowError(int num,
java.lang.String text,
boolean modal,
boolean prefix,
boolean isError)
Manufacture one or more error texts based on the given parameters, if silent error mode is
enabled, then these error numbers and the respective generated error text messages will be
stored in the error list, otherwise this generated error texts will be used to display
modal or modeless box in the UI.
|
static void |
recordOrShowError(int num,
java.lang.String text,
boolean modal,
boolean prefix,
boolean isError,
boolean asMsg)
Manufacture one or more error texts based on the given parameters, if silent error mode is
enabled, then these error numbers and the respective generated error text messages will be
stored in the error list, otherwise this generated error texts will be used to display
modal or modeless box in the UI.
|
static void |
recordOrShowWarning(int num,
java.lang.String text,
boolean prefix,
boolean isError,
boolean asMsg,
boolean addDot)
Manufacture one or more warning texts based on the given parameters.
|
static void |
recordOrThrowError(int[] nums,
java.lang.String[] texts,
boolean prefix)
Raise an error condition and optionally record the given error (in silent mode).
|
static void |
recordOrThrowError(int[] nums,
java.lang.String[] texts,
boolean prefix,
boolean asMsg)
Raise an error condition and optionally record the given error (in silent mode).
|
static void |
recordOrThrowError(int num,
java.lang.String text)
Raise an error condition and optionally record the given error (in silent mode).
|
static void |
recordOrThrowError(int num,
java.lang.String text,
boolean prefix)
Raise an error condition and optionally record the given error (in silent mode).
|
static void |
recordOrThrowError(int num,
java.lang.String text,
boolean prefix,
boolean asMsg)
Raise an error condition and optionally record the given error (in silent mode).
|
static void |
recordOrThrowError(int num,
java.lang.String text,
NumberedException error)
Raise an error condition and optionally record a chain of errors (in silent mode).
|
static void |
recordOrThrowError(NumberedException error)
Raise an error condition and optionally record a chain of errors (in silent mode).
|
static void |
resetClient()
Reverts the error data access on the client.
|
static void |
setCanFindBracket(boolean enter)
Sets silent mode during CAN-FIND calls.
|
static void |
setError(boolean value)
Sets the error variable.
|
static void |
setError(logical value)
Sets the error variable.
|
(package private) static void |
setErrorObjectDetail(SOAPFaultImpl fault)
Set the ERROR-OBJECT-DETAIL attribute, a handle of type SOAP-FAULT.
|
static void |
setHeadless()
Initialize
ErrorManager for headless mode. |
static void |
setIgnore(boolean value)
Sets the
ignore variable. |
static void |
setNumErrors(int64 errCount)
Undocumented feature encountered in customer code.
|
static void |
setPending(boolean value)
Sets the
pendingError variable. |
static void |
setSilent(boolean value)
Sets the
silent variable. |
static void |
setSuppressWarnings(boolean value)
This method can be only called on the server.
|
static void |
setSystemAlertBoxes(boolean on)
Set the state of SESSION:SYSTEM-ALERT-BOXES attribute.
|
static void |
showErrorAndAbend(int[] num,
java.lang.String[] text)
Manufacture one or more error texts based on the given parameters, if
silent error mode is enabled, then these error numbers and the
respective generated error text messages will be stored in the error
list, otherwise this generated error texts will be used to display a
modal, alert (error) box in the UI.
|
static void |
showErrorAndAbend(int num,
java.lang.String text)
Manufacture error text based on the given parameters; after displaying
the error text on the client, a pause is forced before stopping the
application.
|
static boolean |
silent(java.lang.Runnable code)
Worker method that executes a given block of code with silent error mode turned on for
the duration of the code block.
|
static void |
stopBatchSession()
Stops the associated client session by generating UnstoppableExitException.
|
static RemoteErrorData |
switchErrorStorage(RemoteErrorData instance)
Switch the error storage to the specified instance.
|
static void |
throwError(int num,
java.lang.String text,
NumberedException error)
Display error text and throw an exception based upon the given
exception.
|
static void |
throwError(int num,
java.lang.String text,
NumberedException error,
boolean suppress)
Display error text and throw an exception based upon the given exception.
|
static void |
throwError(NumberedException error)
Display error text and throw an exception based upon the given
exception.
|
static void |
throwError(NumberedException error,
boolean suppress)
Display error text and throw an exception based upon the given exception.
|
static boolean |
unknown()
Implementation for the
WrappedResource.unknown() API. |
static boolean |
valid()
Implementation for the
WrappedResource.valid() API. |
static void |
warningModeDisable()
Disables warning mode.
|
static void |
warningModeEnable()
Enables warning mode, during which errors are non-fatal, but are
reported to the UI of the current context via a call to
LogicalTerminal.message() . |
private static final int ERR_CONDITIONS_CAPACITY
private static final java.util.logging.Logger LOG
private static ErrorManager.ContextContainer work
private static RemoteErrorData da
private static final RemoteErrorData local
private static boolean headless
private static ErrorWriter errorWriter
private static boolean serverSide
public static RemoteErrorData getLocalAccess()
RemoteErrorData
implementation which uses local storage.
Can be used on client-side only.public static RemoteErrorData switchErrorStorage(RemoteErrorData instance)
instance
- The RemoteErrorData
implementation.da
reference.public static handle asHandle()
StaticProxy.obtain(Class, Class[])
, using the
CommonErrorStatus
interface and its methods implemented by these
classes: ErrorManager
.public static java.lang.Long id()
public static void id(long id)
This is a no-op for system handles.
id
- The resource's ID.public static boolean valid()
WrappedResource.valid()
API.public static boolean unknown()
WrappedResource.unknown()
API.public static void readOnlyError(java.lang.String attribute)
attribute
- The attribute's name.handle.readOnlyError(handle, String)
public static void setHeadless()
ErrorManager
for headless mode.public static void setSystemAlertBoxes(boolean on)
on
- The new state for SESSION:SYSTEM-ALERT-BOXES attribute.public static boolean isSystemAlertBoxes()
public static void setCanFindBracket(boolean enter)
ErrorManager
will run similar to headless mode
and will silently discard error messages.
NoteAlways call this method in pairs (one with enter = true before executing the query and, one with enter = false, immediately after) to assure the correct management of the headless context flag.
enter
- If true
will increment the nested CAN-FIND count.public static boolean isInCanFindBracket()
true
if currently a CAN-FIND is executed.public static void initClient(RemoteErrorData errorServer)
errorServer
- The remote error interfacepublic static void initErrorWriter(ErrorWriter errorWriterInitial)
errorWriterInitial
- Error writer implementation for client side.public static boolean isInBatchMode()
true
for batch mode, false
otherwise.public static void stopBatchSession()
public static void resetClient()
public static boolean isSilentError()
true
if silent mode is enabled, otherwise
false
.public static boolean isWarningMode()
true
if warning mode is enabled, otherwise
false
.public static boolean silent(java.lang.Runnable code)
This method can only be executed on the server side.
code
- The block of code to execute in silent mode.public static void warningModeEnable()
LogicalTerminal.message()
.
Each call to this method must be matched with a corresponding call
to warningModeDisable()
.
public static void warningModeDisable()
Each call to this method must be matched with a corresponding, previous
call to warningModeEnable()
.
public static void recordOrShowError(int num, java.lang.String text, boolean modal)
The error message(s) will be prefixed with **
and the pending
error flag will be set to true
.
num
- The error number.text
- The text of the error message.modal
- true
if message will be shown in modal dialog.public static void recordOrShowError(int[] num, java.lang.String[] text, boolean modal)
The error message(s) will be prefixed with **
and the pending
error flag will be set to true
.
num
- The error number.text
- The text of the error message.modal
- true
if message will be shown in modal dialog.public static void recordOrShowError(int num, java.lang.String text, boolean modal, boolean prefix)
The error message(s) will be prefixed with **
depending on the
prefix
parameter and the pending
error flag will be set to
true
.
num
- The error number.text
- The text of the error message.modal
- true
if message will be shown in modal dialog.prefix
- true
to prepend a double asterisk prefix to the formatted error
message, false
to omit this text.public static void recordOrShowError(int[] num, java.lang.String[] text, boolean modal, boolean prefix)
The error message(s) will be prefixed with **
depending on the
prefix
parameter and the pending
error flag will be set to
true
.
num
- The error number.text
- The text of the error message.modal
- true
if message will be shown in modal dialog.prefix
- true
to prepend a double asterisk prefix to the formatted error
message, false
to omit this text.public static void recordOrShowError(int num, java.lang.String text, boolean modal, boolean prefix, boolean isError)
The error message(s) will be prefixed with **
depending on the
prefix
parameter and the pending
error flag will be set to the
value specified by the isError
flag.
num
- The error number.text
- The text of the error message.modal
- true
if message will be shown in modal dialog.prefix
- true
to prepend a double asterisk prefix to the formatted error
message, false
to omit this text.isError
- The new value for the pending
error flag.public static void recordOrShowError(int num, java.lang.String text, boolean modal, boolean prefix, boolean isError, boolean asMsg)
The error message(s) will be prefixed with **
depending on the
prefix
parameter and the pending
error flag will be set to the
value specified by the isError
flag.
num
- The error number.text
- The text of the error message.modal
- true
if message will be shown in modal dialog.prefix
- true
to prepend a double asterisk prefix to the formatted error
message, false
to omit this text.isError
- The new value for the pending
error flag.asMsg
- true
to use the given text as the message text else
false
to use buildErrorText.public static void recordOrShowError(int[] num, java.lang.String[] text, boolean modal, boolean prefix, boolean isError)
The error message(s) will be prefixed with **
depending on the
prefix
parameter and the pending
error flag will be set to the
value specified by the isError
flag.
num
- The error number.text
- The text of the error message.modal
- true
if message will be shown in modal dialog.prefix
- true
to prepend a double asterisk prefix to the formatted error
message, false
to omit this text.isError
- The new value for the pending
error flag.public static void recordOrShowError(int[] num, java.lang.String[] text, boolean modal, boolean prefix, boolean isError, boolean asMsg)
The error message(s) will be prefixed with **
depending on the
prefix
parameter and the pending
error flag will be set to the
value specified by the isError
flag.
num
- The error number.text
- The text of the error message.modal
- true
if message will be shown in modal dialog.prefix
- true
to prepend a double asterisk prefix to the formatted error
message, false
to omit this text.isError
- The new value for the pending
error flag.asMsg
- true
to use the given text as the message text else
false
to use buildErrorText.public static void recordOrShowError(int[] num, java.lang.String[] text, boolean modal, boolean prefix, boolean isError, boolean asMsg, boolean addDot)
The error message(s) will be prefixed with **
depending on the
prefix
parameter and the pending
error flag will be set to the
value specified by the isError
flag.
num
- The error number.text
- The text of the error message.modal
- true
if message will be shown in modal dialog.prefix
- true
to prepend a double asterisk prefix to the formatted error
message, false
to omit this text.isError
- The new value for the pending
error flag.asMsg
- true
to use the given text as the message text else
false
to use buildErrorText.addDot
- true
if dot(s) are added to the end of the message(s).public static void recordOrShowWarning(int num, java.lang.String text, boolean prefix, boolean isError, boolean asMsg, boolean addDot)
The error message(s) will be prefixed with **
depending on the
prefix
parameter and the pending
error flag will be set to the
value specified by the isError
flag.
num
- The error number.text
- The text of the error message.prefix
- true
to prepend a double asterisk prefix to the formatted error
message, false
to omit this text.isError
- The new value for the pending
error flag.asMsg
- true
to use the given text as the message text else
false
to use buildErrorText.addDot
- true
if dot(s) are added to the end of the message(s).public static void showErrorAndAbend(int num, java.lang.String text) throws StopConditionException
num
- The error number.text
- The text of the error message.StopConditionException
- always, unless the error manager is in ignore mode.public static void conditionalShowErrorAndAbend(int num, java.lang.String text) throws StopConditionException
num
- The error number.text
- The text of the error message.StopConditionException
- always, unless the error manager is in ignore mode.private static void postprocessOnAbend(java.lang.String errmsg)
showErrorAndAbend(int, String)
.errmsg
- Message text.public static void showErrorAndAbend(int[] num, java.lang.String[] text) throws StopConditionException
After error messages has been processed, a STOP condition is raised.
num
- The error numbers.text
- The text of the error messages.StopConditionException
- always, unless the error manager is in ignore mode.private static void postprocessOnAbend(java.lang.String[] text)
showErrorAndAbend(int[], String[])
.text
- Message text.public static void recordOrThrowError(int num, java.lang.String text) throws ErrorConditionException
In silent mode, the silent(java.lang.Runnable)
worker will catch the exception and it will not be
seen by the converted code.
num
- The error number.text
- The text of the error message.ErrorConditionException
public static void recordOrThrowError(int num, java.lang.String text, boolean prefix)
In silent mode, the silent(java.lang.Runnable)
worker will catch the exception and it will not be
seen by the converted code.
num
- The error number.text
- The text of the error message.prefix
- true
to prepend a double asterisk prefix to the
formatted error message, false
to omit this text.ErrorConditionException
public static void recordOrThrowError(int[] nums, java.lang.String[] texts, boolean prefix) throws ErrorConditionException
In silent mode, the silent(java.lang.Runnable)
worker will catch the exception and it will not be
seen by the converted code.
nums
- The error numbers.texts
- The text of the error messages.prefix
- true
to prepend a double asterisk prefix to the
formatted error message, false
to omit this text.ErrorConditionException
public static void recordOrThrowError(int[] nums, java.lang.String[] texts, boolean prefix, boolean asMsg) throws ErrorConditionException
In silent mode, the silent(java.lang.Runnable)
worker will catch the exception and it will not be
seen by the converted code.
nums
- The error numbers.texts
- The text of the error messages.prefix
- true
to prepend a double asterisk prefix to the
formatted error message, false
to omit this text.asMsg
- true
to use the given text as the message text else
false
to use buildErrorText.ErrorConditionException
public static void recordOrThrowError(int num, java.lang.String text, boolean prefix, boolean asMsg)
In silent mode, the silent(java.lang.Runnable)
worker will catch the exception and it will not be
seen by the converted code.
num
- The error number.text
- The text of the error message.prefix
- true
to prepend a double asterisk prefix to the
formatted error message, false
to omit this text.asMsg
- true
to use the given text as the message text else
false
to use buildErrorText.ErrorConditionException
public static void recordOrThrowError(int num, java.lang.String text, NumberedException error)
In silent mode, the silent(java.lang.Runnable)
worker will catch the exception and it will not be
seen by the converted code.
In silent mode, the error messages and numbers are extracted from error
and any other instances of NumberedException
present in the chain of root
cause exceptions.
The first error entry recorded is derived from the given error number and text, however.
num
- The error number.text
- The text of the error message.error
- Exception containing an error number, message, and optionally
a root cause chain.public static void recordOrThrowError(NumberedException error)
In silent mode, the silent(java.lang.Runnable)
worker will catch the exception and it will not be
seen by the converted code.
In silent mode, the error messages and numbers are extracted from error
and any other instances of NumberedException
present in the chain of root
cause exceptions.
error
- Exception containing an error number, message, and optionally
a root cause chain.public static void noRecordOrThrowError(java.lang.String msg)
ErrorConditionException
and if in silent mode, it sets the
pending
flag to true
. NO error information (messages or
error numbers) will be recorded in either case (i.e. silent mode or not). In silent
mode the ERROR-STATUS:ERROR
will be true
but the other "records"
of the error that normally exist, will not exist. No message will be displayed. Because
no message is ever displayed or recorded, the normal error number/message processing
is not executed.msg
- The text to use in throwing the error exception.public static void throwError(int num, java.lang.String text, NumberedException error)
error
and any other instances of
NumberedException
present in the chain of root cause
exceptions. The first error entry recorded is derived from the given
error number and text, however.num
- The error number.text
- The text of the error message.error
- Exception containing an error number, message, and optionally
a root cause chain.public static void throwError(NumberedException error)
error
and any other instances of
NumberedException
present in the chain of root cause
exceptions.error
- Exception containing an error number, message, and optionally
a root cause chain.public static void throwError(int num, java.lang.String text, NumberedException error, boolean suppress)
error
and any other instances of
NumberedException
present in the chain of root cause exceptions. The first
error entry recorded is derived from the given error number and text, however.
This version of the method allows explicit control over silent error mode processing. This
means that error processing which is normally suppressed, can be explicitly re-enabled
by passing suppress
as false
even if isSilentError()
would return
true
. ONLY USE THIS IF YOU REALLY KNOW WHAT YOU ARE DOING. Bypassing silent error
mode is usually a bad idea. There are some use cases in the 4GL where this is needed and
so that is why this method exists.
num
- The error number.text
- The text of the error message.error
- Exception containing an error number, message, and optionally a root cause chain.suppress
- true
to suppress the display of error texts, else false
.public static void throwError(NumberedException error, boolean suppress)
error
and any other instances of
NumberedException
present in the chain of root cause exceptions.
This version of the method allows explicit control over silent error mode processing. This
means that error processing which is normally suppressed, can be explicitly re-enabled
by passing suppress
as false
even if isSilentError()
would return
true
. ONLY USE THIS IF YOU REALLY KNOW WHAT YOU ARE DOING. Bypassing silent error
mode is usually a bad idea. There are some use cases in the 4GL where this is needed and
so that is why this method exists.
error
- Exception containing an error number, message, and optionally a root cause chain.suppress
- true
to suppress the display of error texts, else false
.public static java.lang.String buildErrorText(int num, java.lang.String text)
num
- The error number substituted for %i in the format string.text
- The text of the error message substituted for %s in the
format string.public static java.lang.String buildErrorText(int num, java.lang.String text, boolean prefix)
num
- The error number substituted for %i in the format string.text
- The text of the error message substituted for %s in the
format string.prefix
- true
to prepend a double asterisk prefix to the
formatted error message, false
to omit this text.public static java.lang.String buildErrorText(int num, java.lang.String text, boolean prefix, boolean addDot)
num
- The error number substituted for %i in the format string.text
- The text of the error message substituted for %s in the
format string.prefix
- true
to prepend a double asterisk prefix to the
formatted error message, false
to omit this text.addDot
- true
if a dot is added to the end of the message.public static java.lang.String buildAbendText(int num, java.lang.String text)
num
- The error number substituted for %i in the format string.text
- The text of the error message substituted for %s in the
format string.public static void addError(int num, java.lang.String text, boolean errFlag)
num
- The error number.text
- The text of the error message.errFlag
- If false
this should add the number and text to
the error list but not set the error flag. If
true
the error flag should also be set.public static void addError(int num, java.lang.String text, boolean errFlag, boolean prefix)
num
- The error number.text
- The text of the error message.errFlag
- If false
this should add the number and text to
the error list but not set the error flag. If
true
the error flag should also be set.prefix
- true
to prepend a double asterisk prefix to the
formatted error message, false
to omit this text.public static boolean isPendingError()
false
.public static logical isError()
false
will be returned.public static integer numErrors()
public static void setNumErrors(int64 errCount)
errCount
- New value.public static integer getErrorNumber(integer index)
index
- Position in the error list from which to return the entry.
This is 1-based list index, where 1 is the oldest error number
and highest number is the most recent error number.public static integer getErrorNumber(int index)
index
- Position in the error list from which to return the entry.
This is 1-based list index, where 1 is the oldest error number
and highest number is the most recent error number.public static integer getErrorNumberAtIndex(long index)
This will return the error number found on the error stack at the given position, or 0 if there isn't any error in the stack at the given position.
This implementation always will return 0 for any non-positive number (0 or negative).
In the 4GL, some negative numbers will return what appears to be a random number. This is most likely a flaw in the 4GL implementation where there is improper boundary testing and an invalid index value is used to dereference memory that is not associated with the error stack.
As such the behavior is non-deterministic and also is a likely security flaw.
This implementation is deliberately not duplicating this bad behavior and it seems unlikely that an application would be coded to rely upon it.
index
- The position of the stack from which we want to get the value error number.
This should be greater than 0 for valid results.
This is 1-based stack offset, where 1 is the most recent error number
and highest number is oldest error number in the stack.public static integer getErrorNumberAtIndex(integer index)
This will return the error number found on the error stack at the given position, or 0 if there isn't any error in the stack at the given position.
This implementation always will return 0 for any non-positive number (0 or negative).
In the 4GL, some negative numbers will return what appears to be a random number. This is most likely a flaw in the 4GL implementation where there is improper boundary testing and an invalid index value is used to dereference memory that is not associated with the error stack.
As such the behavior is non-deterministic and also is a likely security flaw.
This implementation is deliberately not duplicating this bad behavior and it seems unlikely that an application would be coded to rely upon it.
index
- The position of the stack from which we want to get the value error number.
This should be greater than 0 for valid results.
This is 1-based stack offset, where 1 is the most recent error number
and highest number is oldest error number in the stack.public static integer getErrorNumberAtIndex(int64 index)
This will return the error number found on the error stack at the given position, or 0 if there isn't any error in the stack at the given position.
This implementation always will return 0 for any non-positive number (0 or negative).
In the 4GL, some negative numbers will return what appears to be a random number. This is most likely a flaw in the 4GL implementation where there is improper boundary testing and an invalid index value is used to dereference memory that is not associated with the error stack.
As such the behavior is non-deterministic and also is a likely security flaw.
This implementation is deliberately not duplicating this bad behavior and it seems unlikely that an application would be coded to rely upon it.
index
- The position of the stack from which we want to get the value error number.
This should be greater than 0 for valid results.
This is 1-based stack offset, where 1 is the most recent error number
and highest number is oldest error number in the stack.public static java.util.LinkedList<java.lang.Integer> getRaisedConditions()
static void addRaisedCondition(int[] errNums)
errNums
- errors numbers.public static character getErrorText(integer index)
index
- Position in the error list from which to return the entry.public static character getErrorText(int index)
index
- Position in the error list from which to return the entry.public static boolean isSilent()
silent
variable.true
if silent mode is enabled, otherwise
false
.public static void setSilent(boolean value)
silent
variable.value
- The new state of the variable.public static boolean isIgnore()
ignore
variable.true
if ignore mode is enabled, otherwise
false
.public static void setIgnore(boolean value)
ignore
variable.value
- The new state of the variable.public static boolean isErrorFlag()
error
variable.true
if error flag is turned on, otherwise
false
.public static void setError(boolean value)
value
- The new state of the variable.public static void setError(logical value)
value
- The new state of the variable.public static boolean isPending()
pendingError
variable.true
if pending error flag is turned on, otherwise
false
.public static void setPending(boolean value)
pendingError
variable.value
- The new state of the variable.public static boolean isHeadless()
true
if the headless flag is turned on, otherwise false
.public static int getSize()
public static void addRecord(java.lang.Object record)
record
- The object to add to the list of error records.public static java.lang.Object getRecord(int index)
index
- The record index.public static void clearPending()
public static void forwardPending()
public static void displayError(int num, java.lang.String msg)
num
- Error number.msg
- The text to display in the message line.public static void displayError(int num, java.lang.String msg, boolean prefix)
num
- Error number.msg
- The text to display in the message line.prefix
- true
to prepend a double asterisk prefix to the
formatted error message, false
to omit this text.public static void displayWarning(int num, java.lang.String msg)
num
- Error number.msg
- The text to display.public static void displayWarning(int num, java.lang.String msg, boolean prefix)
num
- Error number.msg
- The text to display.prefix
- true
to prepend a double asterisk prefix to the
formatted error message, false
to omit this text.public static void displayErrorRedirected(int num, java.lang.String msg, boolean prefix)
num
- Error number.msg
- The text to display in the message line.prefix
- true
to prepend a double asterisk prefix to the
formatted error message, false
to omit this text.public static void displayErrorRedirected(java.lang.String msg)
msg
- The text to display in the message line.public static void displayAbend(int num, java.lang.String msg)
num
- Error number.msg
- The text to display in the message line.public static void displayError(java.lang.String errmsg)
errmsg
- The text to display in the message line.public static void displayError(java.lang.String errmsg, boolean noMessageBox)
errmsg
- The text to display in the message line.noMessageBox
- true
if error is always displayed in message area or logged rather
than displayed as a message box.public static void displayWarning(java.lang.String wrnmsg)
wrnmsg
- The text to display in the message line.public static character getResourceType()
public static handle getErrorObjectDetail()
public static boolean isSuppressWarnings()
public static void setSuppressWarnings(boolean value)
value
- static void setErrorObjectDetail(SOAPFaultImpl fault)
If the handle is valid and the referred resource is not a SOAPFault
instance, then
this will throw a RuntimeException
.
If the handle is null
or invalid, the ErrorManager.WorkArea.pendingErrorStatus
's
soapFault
field will be set to null
.
fault
- The resource representing the soap-fault.static java.util.Iterator<java.lang.String> errorTexts(java.lang.Throwable error)
error
(including its possible
chain of root causes).error
- A throwable which is an instance of
NumberedException
or which contains instances
thereof.static java.util.Iterator<java.lang.String> errorTexts(int num, java.lang.String text, java.lang.Throwable error)
error
(including its possible
chain of root causes), and from the given error number and text.num
- Error number of the first message to occur in the resulting
iteration.text
- Error text of the first message to occur in the resulting
iteration.error
- A throwable which is an instance of
NumberedException
or which contains instances
thereof.private static java.util.Iterator<java.lang.String> errorTexts(java.util.List<ErrorManager.ErrorEntry> entries)
ErrorEntry
objects stored in a list.entries
- List of error entries.private static java.util.List<ErrorManager.ErrorEntry> compileErrorEntries(java.lang.Throwable error)
error
and any chained root cause exceptions
of type NumberedException
error messages and numbers with which to compile a list of error
entries. This list is compiled in reverse order of the root cause
chain traversal, such that the most specific errors appear earliest in
the list. If no instances of NumberedException
are
detected during the traversal, the list will be empty.error
- Error from which to extract error messages and numbers.ErrorEntry
objects.private static void log(java.lang.String message, boolean silent)
message
- The text to insert into the log.silent
- true
if silent error mode is active.private static void log(java.lang.String message, java.lang.Throwable trw, boolean silent)
message
- The text to insert into the log.trw
- The cause of the failure.silent
- true
if silent error mode is active.