Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Function GetException(Message : String) : Aggregate Of Exception
  • Procedure CancelException

 


Function GetException(Message : String) : Aggregate Of Exception;
   Local
      lInnerException : Exception;
      lMessage : String;
      lKeep : Boolean := True;
   End_Local;
   If NVL(xpxExceptionId.errCode, 0) <> 0 Then
      -- EDM error
      -- Avoid reporting the same error twice
      Repeat I := 1 To xpfSizeOf(GExceptions);
         If (GExceptions[I].errCode = xpxExceptionId.errCode) And
            (GExceptions[I].lineNumber = xpxExceptionId.lineNumber) Then
            lKeep := False;
            Escape;
         End_If;
      End_Repeat;
      If lKeep Then
         lInnerException := GException;
         New GException;
         GException._Type_         := 'edmException';
         GException.errCode        := xpxExceptionId.errCode;
         GException.errMessage     := xpfGetErrorText(xpxExceptionId.errCode);
         GException.functionName   := xpxExceptionId.functionName;
         GException.lineNumber     := xpxExceptionId.lineNumber;
         GException.innerException := lInnerException;
         lMessage := xpfStringPrintf('Line #%d: Exception. EDM Error number: %d, Message: %s', NVL(xpxExceptionId.lineNumber, xpxCurrentLine), GException.errCode, GException.errMessage);
         xpxPrintf('%s\n', lMessage); xpxDebugPrintf('%s\n', lMessage);
         GExceptions ++ GException;
       End_If;
   End_If;
   If NVL(Message, '') <> '' Then
      lInnerException := GException;
      New GException;
      GException._Type_         := 'xpxException';
      GException.userMessage    := Message;
      GException.innerException := lInnerException;
      lMessage := xpfStringPrintf('Line #%d: Exception: Message: %s', NVL(xpxExceptionId.lineNumber, xpxCurrentLine), GException.userMessage);
      xpxPrintf('%s\n', lMessage); xpxDebugPrintf('%s\n', lMessage);
      GExceptions ++ GException;
   End_If;
   Return(GExceptions);
End_Function;

...


To ignore an exception and reset exception chain:
     On_Error_Do cancelException; End_On_Error_Do;


Catch the XPXException in edmiNET like this:
   
edmiNet VB:

Code Block
languagevb
title.Net VB Example
linenumberstrue
Try
   EnterpriseModel.NewQuery.Execute("CatDictionaryServices", "UpdateExchangeRequirementConceptAttribute", New Object() {New Instance(ProductPage.ERConceptId),
                                                                                                                                     New Instance(lGroupId),
                                                                                                                                     New Instance(lConceptId),
                                                                                                                                     Column.Name, NewValue})
    RefreshRow = True
Catch XPXEx As XPXException
    XtraMessageBox.Show(XPXEx.Message)
Catch Ex As Exception
    XtraMessageBox.Show(Ex.ToString)
End Try

edmiNet C#:

Code Block
languagec#
title.NET C# Example
linenumberstrue
try {
		EnterpriseModel.NewQuery.Execute("CatDictionaryServices", "UpdateExchangeRequirementConceptAttribute", new object[] {
			new Instance(ProductPage.ERConceptId),
			new Instance(lGroupId),
			new Instance(lConceptId),
			Column.Name,
			NewValue
		});
		RefreshRow = true;
} catch (XPXException XPXEx) {
		XtraMessageBox.Show(XPXEx.Message);
} catch (Exception Ex) {
		XtraMessageBox.Show(Ex.ToString);
}

...

Code Block
titleExample output
Error number 11298: Illegal data type or data value of argument #1.
Function: xpfGetInstanceModel
Line number: 1581
Query function: CatDictionaryServices.UpdateExchangeRequirementConceptAttribute

 

...