-
Notifications
You must be signed in to change notification settings - Fork 19
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
fix: com error handling #25
Conversation
Snshadow
commented
Dec 3, 2024
- fix win32.GetClientRect error handling following the semantic
- fix com error handling as the last status maybe set to an error value in previous Windows versions
- fix win32.GetClientRect error handling following the semantic - fix com error handling as the last status maybe set to an error value in previous Windows versions
As the AddRef and Release return a reference count as a uint32 value, I tried changing them to return uint32 value instead of an error(as internally used last status value could be handled inappropriately.) However, I realized that changing the whole AddRef and Release function to return uint32 makes
|
Some errors were accidentally changed to return nil instead of an error. Fixed them with the latest commit. |
50a3222
to
03e9222
Compare
03e9222
to
7b613d0
Compare
Thanks for taking the time to do this - a much needed improvement. I think we'll figure out what to do with the 3 functions above in a separate PR 👍 |
I have create an issue in wails for follow up. |
@@ -293,13 +473,10 @@ func (e *ICoreWebView2Environment) CreateWebResourceResponse(content []byte, sta | |||
} | |||
|
|||
if response == nil { | |||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we remove this?
I mean isn't it better to have at least GetLastError (which might give us more information) returned instead of always unknown error
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But are GetLastError values guaranteed to contain meaningful data(not to be misleading if unrelated function had call SetLastError and not return it to ERROR_SUCCESS
)? Or could it be used just to get indirect gleam of what happened? It thats the case.. I will have to get back all err return value from Proc.Call.. 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leaanthony Any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, those are the same thoughts I had during a fix of the error handling in that function. It's not clear that GetLastError might be helpful or not, that really depends on what's going on behind the scenes which is completely out of our control.
Maybe we could include it has a hint. return fmt.Errorf("uknown error: hint=%w", err)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That all goes into the direction what I brought up in the other issue: wailsapp/wails#3931 (comment)
Then clearly define a set of rules how errors should be handled and detected for com call and afterwards bring go-webview2 as v2 up to that and use it in Wails v3.
We should probably really start a discussion how to handle errors depending on the method being called. E.g. check pointer to Ole-Objects returned to detect if call was successful, and probably other checks, what we should do in the case above...