Main Content

NET.NetException

Capture error information for .NET exception

    Description

    Process information from a NET.NetException object to handle .NET errors. This class is derived from MException.

    Creation

    Description

    e = NET.NetException(msgID,errMsg,netObj) constructs instance e of NET.NetException class.

    example

    Input Arguments

    expand all

    Message identifier, specified as a string or a character vector.

    Error message text, specified as a string or a character vector.

    .NET object that caused the exception, specified as a System.Exception object.

    Properties

    expand all

    Class causing the error, specified as a System.Exception object.

    Object Functions

    See the object functions of MException.

    Examples

    collapse all

    Display error information after trying to load an unknown assembly.

    try
      NET.addAssembly('C:\Work\invalidfile.dll')
    catch e
      e.message;
      if(isa(e, 'NET.NetException'))
        eObj = e.ExceptionObject
      end
    end
    ans =
    Message: Could not load file or assembly 
      'file:///C:\Work\invalidfile.dll' or 
      one of its dependencies. The system cannot 
      find the file specified.
    Source: mscorlib
    HelpLink: 
    
    eObj = 
      FileNotFoundException with properties:
    
               Message: [1x1 System.String]
              FileName: [1x1 System.String]
             FusionLog: [1x1 System.String]
                  Data: [1x1 System.Collections.ListDictionaryInternal]
        InnerException: []
            TargetSite: [1x1 System.Reflection.RuntimeMethodInfo]
            StackTrace: [1x1 System.String]
              HelpLink: []
                Source: [1x1 System.String]
    

    Version History

    Introduced in R2009b

    See Also