Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update COMException to contain HRESULT and introduce COMInvokeException #903

Commits on Jan 13, 2018

  1. Rework COMException to also carry the HRESULT

    This allows filtering exception based on HRESULT value. For example
    GetActiveObject returns a HRESULT of 0x800401E3 (MK_E_UNAVAILABLE)
    if the target object is not active. For many cases this is not an error.
    
    A valid construct would be:
    
    public void getExistingDemoObjectOrCreate() {
    	DemoObject obj;
    	try {
    		return factory.fetchObject(DemoObject.class);
    	} catch (COMException ex) {
    		if(ex.matchesHresult(WinError.MK_E_UNAVAILABLE)) {
    			return factory.createObject(DemoObject.class);
    		} else {
    			throw ex;
    		}
    	}
    }
    matthiasblaesing committed Jan 13, 2018
    Configuration menu
    Copy the full SHA
    22ec699 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    92bbd92 View commit details
    Browse the repository at this point in the history
  3. Introduce COMInvokeException and prevent a memory leak in case of fai…

    …lure
    
    Only a subset of errors contain exception data. Only calls to
    IDispatch#Invoke generate exception details and potentially a "fault
    index" for parameters. Therefore these are separated into an extended
    COMInvokeException.
    
    Additionally the EXCEPINFO data was not freeed, leading to memory leaks
    in in repeated calls.
    
    Add unittest for COMExceptions and correct Exception extraction in Factory
    matthiasblaesing committed Jan 13, 2018
    Configuration menu
    Copy the full SHA
    bb408ff View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    bf680a5 View commit details
    Browse the repository at this point in the history