Packages
 In this topic

*Constructors

*Methods

*Fields

 

Packages   PreviousThis PackageNext
Package com.ms.com   Previous This
Package
Next

 


Class ComException

public abstract class ComException extends RuntimeException
{
  // Fields
  protected int hr;
  protected int m_helpContext;
  protected String m_helpFile;
  protected String m_source;

  // Constructors
  public ComException(int hr);
  public ComException(int hr, String description);
  public ComException(int hr, String source, String helpFile,
        int helpContext);
  public ComException(int hr, String description, String source,
        String helpFile, int helpContext);
  public ComException();
  public ComException(String description);

  // Methods
  public int getHelpContext();
  public String getHelpFile();
  public int getHResult();
  public String getSource();
}

This class wraps an HRESULT, the return type for most methods in the Component Object Model (COM). When you call COM methods from Java, you catch ComException objects to handle error conditions. Because ComException is derived from the RuntimeException class, the compiler does not check whether methods throw ComException objects. Use your discretion as to when you should use try-catch blocks.

When implementing COM classes that use Java, ComException objects are thrown to signal error conditions. Because ComException is an abstract class, a ComException object cannot be constructed directly. However, ComFailException objects and ComSuccessException objects are constructed using ComException constructors.

RuntimeException
  |
  +--ComException

Constructors

ComException

public ComException(int hr);

Creates a ComException object that contains the specified HRESULT.

ParameterDescription
hr The HRESULT value.

ComException

public ComException(int hr, String description);

Creates a ComException object that contains an HRESULT and a description.

ParameterDescription
hr The HRESULT value that is returned.
description The detail description.

ComException

public ComException(int hr, String source, String helpFile,
        int helpContext);

Creates a ComException object that contains the HRESULT, source, Help file, and help context.

ParameterDescription
hr The HRESULT value that is returned.
source The source of the ComException object.
helpFile The Help file that explains the ComException object.
helpContext The identifier that indicates the context of the exception.

ComException

public ComException(int hr, String description, String source,
        String helpFile, int helpContext);

Creates a ComException object that contains the specified HRESULT, description, source, Help file, and Help context.

ParameterDescription
hr The HRESULT value to be returned.
description The detail description.
source The source of the ComException object.
helpFile The Help file that explains the ComException object.
helpContext The identifier that indicates the context of the exception.

ComException

public ComException();

Creates and stores an uninitialized ComException object.

ComException

public ComException(String description);

Creates and stores a ComException object that contains the detail description.

ParameterDescription
description The detail description.

Methods

getHelpContext

public int getHelpContext();

Retrieves the Help context of the ComException object. The Help context is an identifier that indicates the context of the exception.

Return Value:

Returns the Help context of the ComException object.

getHelpFile

public String getHelpFile();

Retrieves the Help file that explains the ComException object.

Return Value:

Returns the Help file that explains the ComException object.

getHResult

public int getHResult();

Retrieves the HRESULT returned by the COM method. To catch a ComException object thrown by a COM method, call this method.

Return Value:

Returns the HRESULT returned by the COM method.

getSource

public String getSource();

Retrieves the source of the ComException object.

Return Value:

Returns the source of the ComException object.

Fields

hr
The HRESULT value.
m_helpContext
The identifier used by the Help file that indicates the context of the exception.
m_helpFile
The help file that explains the ComException object.
m_source
The source of the ComException object.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.