Skip to content

Commit

Permalink
fix: missed error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Snshadow committed Dec 3, 2024
1 parent 0b46159 commit 03e9222
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
14 changes: 7 additions & 7 deletions pkg/edge/ICoreWebView2Controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (i *ICoreWebView2Controller) PutBounds(bounds w32.Rect) error {
uintptr(unsafe.Pointer(&bounds)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -96,7 +96,7 @@ func (i *ICoreWebView2Controller) MoveFocus(reason COREWEBVIEW2_MOVE_FOCUS_REASO
uintptr(reason),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -109,7 +109,7 @@ func (i *ICoreWebView2Controller) AddAcceleratorKeyPressed(eventHandler *ICoreWe
uintptr(unsafe.Pointer(&token)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -121,7 +121,7 @@ func (i *ICoreWebView2Controller) PutIsVisible(isVisible bool) error {
uintptr(boolToInt(isVisible)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -145,7 +145,7 @@ func (i *ICoreWebView2Controller) NotifyParentWindowPositionChanged() error {
uintptr(unsafe.Pointer(i)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -157,7 +157,7 @@ func (i *ICoreWebView2Controller) PutZoomFactor(zoomFactor float64) error {
uintptr(math.Float64bits(zoomFactor)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -170,7 +170,7 @@ func (i *ICoreWebView2Controller) GetZoomFactor() (float64, error) {
uintptr(unsafe.Pointer(&zoomFactorUint64)),
)
if windows.Handle(hr) != windows.S_OK {
return 0.0, nil
return 0.0, windows.Errno(hr)
}
return math.Float64frombits(zoomFactorUint64), nil
}
2 changes: 1 addition & 1 deletion pkg/edge/ICoreWebView2Controller2.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (i *ICoreWebView2Controller2) PutDefaultBackgroundColor(backgroundColor COR
uintptr(col),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
18 changes: 9 additions & 9 deletions pkg/edge/ICoreWebView2Settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (i *ICoreWebView2Settings) PutIsScriptEnabled(isScriptEnabled bool) error {
uintptr(boolToInt(isScriptEnabled)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -87,7 +87,7 @@ func (i *ICoreWebView2Settings) PutIsWebMessageEnabled(isWebMessageEnabled bool)
uintptr(boolToInt(isWebMessageEnabled)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -113,7 +113,7 @@ func (i *ICoreWebView2Settings) PutAreDefaultScriptDialogsEnabled(areDefaultScri
uintptr(boolToInt(areDefaultScriptDialogsEnabled)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -139,7 +139,7 @@ func (i *ICoreWebView2Settings) PutIsStatusBarEnabled(isStatusBarEnabled bool) e
uintptr(boolToInt(isStatusBarEnabled)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -164,7 +164,7 @@ func (i *ICoreWebView2Settings) PutAreDevToolsEnabled(areDevToolsEnabled bool) e
uintptr(boolToInt(areDevToolsEnabled)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -189,7 +189,7 @@ func (i *ICoreWebView2Settings) PutAreDefaultContextMenusEnabled(enabled bool) e
uintptr(boolToInt(enabled)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -215,7 +215,7 @@ func (i *ICoreWebView2Settings) PutAreHostObjectsAllowed(allowed bool) error {
uintptr(boolToInt(allowed)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -241,7 +241,7 @@ func (i *ICoreWebView2Settings) PutIsZoomControlEnabled(enabled bool) error {
uintptr(boolToInt(enabled)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -267,7 +267,7 @@ func (i *ICoreWebView2Settings) PutIsBuiltInErrorPageEnabled(enabled bool) error
uintptr(boolToInt(enabled)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
2 changes: 1 addition & 1 deletion pkg/edge/ICoreWebView2WebResourceRequestedEventArgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (i *ICoreWebView2WebResourceRequestedEventArgs) PutResponse(response *ICore
uintptr(unsafe.Pointer(response)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/edge/corewebview2.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ func (i *ICoreWebView2) AddWebResourceRequestedFilter(uri string, resourceContex
uintptr(resourceContext),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
Expand All @@ -643,7 +643,7 @@ func (i *ICoreWebView2) OpenDevToolsWindow() error {
uintptr(unsafe.Pointer(i)),
)
if windows.Handle(hr) != windows.S_OK {
return nil
return windows.Errno(hr)
}
return nil
}
2 changes: 1 addition & 1 deletion pkg/webview2/ICoreWebView2_7.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (i *ICoreWebView2_7) PrintToPdf(ResultFilePath string, printSettings *ICore
// Convert string 'ResultFilePath' to *uint16
_ResultFilePath, err := UTF16PtrFromString(ResultFilePath)
if err != nil {
return nil
return err
}

hr, _, _ := i.Vtbl.PrintToPdf.Call(
Expand Down

0 comments on commit 03e9222

Please sign in to comment.