@staticmethod
def check_error(hresult):
    """Check a given HRESULT for errors.

        Throws an error for non-S_OK HRESULTs.

        """
    S_OK = 0
    E_NOINTERFACE = 2147500034
    E_POINTER = 2147500035
    E_OUTOFMEMORY = 2147942414
    E_INVALIDARG = 2147942487
    AUDCLNT_E_UNSUPPORTED_FORMAT = 2290679816
    if hresult == S_OK:
        return
    elif hresult + 2 ** 32 == E_NOINTERFACE:
        raise RuntimeError(
            'The specified class does not implement the requested interface, or the controlling IUnknown does not expose the requested interface.'
            )
    elif hresult + 2 ** 32 == E_POINTER:
        raise RuntimeError('An argument is NULL.')
    elif hresult + 2 ** 32 == E_INVALIDARG:
        raise RuntimeError('invalid argument')
    elif hresult + 2 ** 32 == E_OUTOFMEMORY:
        raise RuntimeError('out of memory')
    elif hresult + 2 ** 32 == AUDCLNT_E_UNSUPPORTED_FORMAT:
        raise RuntimeError('unsupported format')
    else:
        raise RuntimeError('Error {}'.format(hex(hresult + 2 ** 32)))
