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
public ComException(int hr);
Creates a ComException object that contains the specified HRESULT.
| Parameter | Description |
| hr
| The HRESULT value.
|
public ComException(int hr, String description);
Creates a ComException object that contains an HRESULT and a description.
| Parameter | Description |
| hr
| The HRESULT value that is returned.
|
| description
| The detail description.
|
public ComException(int hr, String source, String helpFile,
int helpContext);
Creates a ComException object that contains the HRESULT, source, Help file, and help context.
| Parameter | Description |
| 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.
|
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.
| Parameter | Description |
| 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.
|
public ComException();
Creates and stores an uninitialized ComException object.
public ComException(String description);
Creates and stores a ComException object that contains the detail description.
| Parameter | Description |
| description
| The detail description.
|
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.
public String getHelpFile();
Retrieves the Help file that explains the ComException object.
Return Value:
Returns the Help file that explains the ComException object.
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.
public String getSource();
Retrieves the source of the ComException object.
Return Value:
Returns the source of the ComException object.
- 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.