Skip to content

Commit

Permalink
Remove unused HRESULT in native system error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
itm4n committed Jan 10, 2025
1 parent 1ee9cc1 commit 09ae885
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/core/WinApi.Wrappers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function Format-Error {
$ErrorObject = [ComponentModel.Win32Exception] $Code
$ErrorMessage = "$($ErrorObject.Message)"
if ($ErrorObject.NativeErrorCode -ge 0) { $ErrorMessage += " ($($ErrorObject.NativeErrorCode))" }
$ErrorMessage += " - HRESULT: $('0x{0:x8}' -f $ErrorObject.HResult)"
return $ErrorMessage
}
}
Expand Down Expand Up @@ -185,7 +184,7 @@ function Get-FileHandle {
$FileHandle = $script:Kernel32::CreateFile($Path, $AccessRights, $ShareMode, [IntPtr]::Zero, 3, $FlagsAndAttributes, [IntPtr]::Zero)
if ($FileHandle -eq -1) {
$LastError = [Runtime.InteropServices.Marshal]::GetLastWin32Error()
Write-Warning "CreateFile('$($Path)') - $(Format-Error $LastError)"
Write-Error "CreateFile('$($Path)') - $(Format-Error $LastError)"
}

return $FileHandle
Expand Down

0 comments on commit 09ae885

Please sign in to comment.