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

Clean up HRESULT error handling #73

Closed
timsneath opened this issue Jul 17, 2020 · 0 comments · Fixed by #74
Closed

Clean up HRESULT error handling #73

timsneath opened this issue Jul 17, 2020 · 0 comments · Fixed by #74
Assignees

Comments

@timsneath
Copy link
Contributor

timsneath commented Jul 17, 2020

We handle errors inconsistently here.

Win32 defines an HRESULT as a signed value:

typedef LONG HRESULT;
typedef long LONG;

Typically it is shown as a const value (e.g. 0x800401F0), but when assigned to a Dart int, that is of course a positive value. To minimize confusion and retain consistency with COM:

  • An HRESULT is treated as a signed int in Dart, rather than a positive 0x80000000 value.
  • COM error constants will be converted to signed 32-bit values

The primary change to the code is that a line like:

const CO_E_NOTINITIALIZED = 0x800401F0;

will become

final CO_E_NOTINITIALIZED = 0x800401F0.toSigned(32);

While this adds some pain to the constants.dart file, this will remove some .toUnsigned(32) calls in the code and therefore avoid the risk of a returned HRESULT failing an equality test with a constant.

We'll need to make some updates to the code to test this consistently; I suspect there's a bug farm lurking here already that this work will root out. Good opportunity for more tests.

@timsneath timsneath self-assigned this Jul 17, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant