The ComException Class of the com.ms.com package is a subclass of java.lang.RuntimeException. It wraps an HRESULT, the return type for most methods in the Component Object Model (COM).
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(); }
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