Handling .NET errors

Posted by Thomas Mercer-Hursh on 27-Apr-2015 10:17

I am working on adding Proparse to ABL2DB and am running into issues where Proparse is throwing an error.  Using the code which I will show below, I have gotten this to where the process will complete and the error messages documenting the issues are put in the log, but I am still having the dialog box for the error come up and stop the processing.  For what is conceptually a batch process, this is irritating.   Is there a way that I can keep these .NET errors from throwing the dialog box?

  method private void ProcessShared (
      ipchCUID as character
      ):
    do on stop undo, retry:
      if retry
      then do:
        log-manager:write-message ("STOP condition encountered in BuildShared", "SYSERROR").
        return.
      end.
    
      do on error undo, leave:    
        obJavaFile = new java.io.File(chFullPath).
        obParseUnit = new ParseUnit(obJavaFile).
        obParseUnit:treeParser01().       
        
        TreeWalker(obParseUnit:getTopNode() ).
    
        BuildReferences( ipchCUID ).
        
        empty temp-table ttShared.
        
        catch eobAppError as Progress.Lang.AppError:
          log-manager:write-message ( eobAppError:ReturnValue ).  
          delete object eobAppError.
        end catch.
      
        catch eobSysError as Progress.Lang.SysError :
          define variable inWhich as integer no-undo.
          log-manager:write-message(substitute("Unexpected Exception: &1", eobSysError:getMessage(1)), "SYSERROR").
          if eobSysError:NumMessages > 1
          then do inWhich = 2 to eobSysError:NumMessages:
            log-manager:write-message(substitute("Unexpected Exception (cont.): &1", eobSysError:getMessage(inWhich)), "SYSERROR").
          end.
          do inWhich = 1 to num-entries(eobSysError:CallStack,"~n"):
            log-manager:write-message(entry(inWhich,eobSysError:CallStack,"~n"),"CALLSTACK").
          end.
          delete object eobSysError no-error.
        end catch.
      end. /* do on error */
    end. /* do on stop */

  end method.


All Replies

Posted by Mike Fechner on 27-Apr-2015 10:23

Structured error handling 1x1 ….
 
A System.Exception inherits the Progress.Lang.Error interface (like SysError and AppError).
 
So either catch System.Exception or Progress.Lang.Error. You can even catch a more specific .NET Exception type.
 
Von: Thomas Mercer-Hursh [mailto:bounce-tamhas@community.progress.com]
Gesendet: Montag, 27. April 2015 17:18
An: TU.OE.Development@community.progress.com
Betreff: [Technical Users - OE Development] Handling .NET errors
 
Thread created by Thomas Mercer-Hursh

I am working on adding Proparse to ABL2DB and am running into issues where Proparse is throwing an error.  Using the code which I will show below, I have gotten this to where the process will complete and the error messages documenting the issues are put in the log, but I am still having the dialog box for the error come up and stop the processing.  For what is conceptually a batch process, this is irritating.   Is there a way that I can keep these .NET errors from throwing the dialog box?

  method private void ProcessShared (
      ipchCUID as character
      ):
    do on stop undo, retry:
      if retry
      then do:
        log-manager:write-message ("STOP condition encountered in BuildShared", "SYSERROR").
        return.
      end.
    
      do on error undo, leave:    
        obJavaFile = new java.io.File(chFullPath).
        obParseUnit = new ParseUnit(obJavaFile).
        obParseUnit:treeParser01().       
        
        TreeWalker(obParseUnit:getTopNode() ).
    
        BuildReferences( ipchCUID ).
        
        empty temp-table ttShared.
        
        catch eobAppError as Progress.Lang.AppError:
          log-manager:write-message ( eobAppError:ReturnValue ).  
          delete object eobAppError.
        end catch.
      
        catch eobSysError as Progress.Lang.SysError :
          define variable inWhich as integer no-undo.
          log-manager:write-message(substitute("Unexpected Exception: &1", eobSysError:getMessage(1)), "SYSERROR").
          if eobSysError:NumMessages > 1
          then do inWhich = 2 to eobSysError:NumMessages:
            log-manager:write-message(substitute("Unexpected Exception (cont.): &1", eobSysError:getMessage(inWhich)), "SYSERROR").
          end.
          do inWhich = 1 to num-entries(eobSysError:CallStack,"~n"):
            log-manager:write-message(entry(inWhich,eobSysError:CallStack,"~n"),"CALLSTACK").
          end.
          delete object eobSysError no-error.
        end catch.
      end. /* do on error */
    end. /* do on stop */
 
  end method.

 

Stop receiving emails on this subject.

Flag this post as spam/abuse.

Posted by Thomas Mercer-Hursh on 27-Apr-2015 10:46

I'll give that a try. Prior to this I hadn't tried anything with a .NET
aspect.

As a side note I will observe that some of what is bothering Proparse
are some very ugly things in the code. Part of the code base I am using
for testing dates back to the mid 1980s and I am being surprised at some
of what is lingering there! :)

This thread is closed