------- Create an new innermost exception representing the current xpxExceptionId object
Function GetEDMException : Aggregate Of Exception;
GExceptions := [];
CreateEDMException;
Return(GExceptions);
End_Function;
Procedure NewEDMException;
GExceptions := [];
CreateEDMException;
End_Procedure;
-- Create an new "selfmade" innermost exception -------------------------------------------------------------------------
-- Declare in beginning of every function to ensure that all EDM errors are
-- caught and that exceptions propagate upwords in the stack.
-- On_Error_Do xpxThrow(GetException(?)); End_On_Error_Do;
-- Throw "soft" errors from code like this:
-- xpxThrow(GetException('Something when wrong'));
-- To ignore an exception and reset exception chain:
-- On_Error_Do cancelException; End_On_Error_Do;
Function GetException(Message : String) : Aggregate Of Exception;
Local
GExceptions := []; lInnerException : NewOuterException(Message)Exception;
Return(GExceptions);
End_FunctionLocal;
ProcedureIf NewException(Message : String);
GExceptions := [];NVL(xpxExceptionId.errCode, 0) <> 0 Then
NewOuterException(Message); End_Procedure; -- CreateEDM anerror
new outer exception on the previous (inner) exception
Function GetOuterException(Message : String) : Aggregate Of ExceptionlInnerException := GException;
New GException;
NewOuterException(Message); GException._Type_ Return(GExceptions); End_Function; Procedure NewOuterException(Message := String)'edmException';
Local GException.errCode lInnerException := ExceptionxpxExceptionId.errCode;
End_Local; GException.errMessage lInnerException := GException;xpfGetErrorText(xpxExceptionId.errCode);
New GException.functionName := xpxExceptionId.functionName;
GException._Type_ lineNumber := xpxExceptionId.lineNumber;
GException.innerException := 'xpxException'lInnerException;
GException.userMessage := Message;
GException.innerException := lInnerException; xpxPrintf('Line #%d: Exception. EDM Error number: %d, Message: %s', xpxCurrentLine, GException.errCode, GException.errMessage);
GExceptions ++ GException;
End_ProcedureIf;
Procedure CreateEDMException; If NVL(Message, Local'') <> '' Then
lInnerException := ExceptionGException;
End_Local; New lInnerException := GException;
New GException; GException._Type_ := 'edmExceptionxpxException';
GException.errCodeuserMessage := Message;
GException.innerException := xpxExceptionId.errCodelInnerException;
GException.errMessage := xpxExceptionId.errMessage;
GException.functionName := xpxExceptionId.functionName;
GException.lineNumber := xpxExceptionId.lineNumber;
GException.innerException := lInnerException;
GExceptions ++ GException;
End_procedure; xpxPrintf('Line #%d: Exception: Message: %s', xpxCurrentLine, GException.userMessage);
GExceptions ++ GException;
End_If;
Return(GExceptions);
End_Function;
-- To ignore an exception from lower level and continue
-- execution as normal call the following function.
Procedure CancelException;
GExceptions := [];
GException := ?;
End_Procedure;
--------------------------------------------------------------------------------------------- |