mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-04-06 06:38:31 +00:00
null-safe patches
This commit is contained in:
@@ -46,11 +46,22 @@ function Set-WinUtilRegistry {
|
||||
} catch [System.Security.SecurityException] {
|
||||
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
|
||||
} catch [System.Management.Automation.ItemNotFoundException] {
|
||||
Write-Warning $psitem.Exception.ErrorRecord
|
||||
Write-Warning $_.Exception.ErrorRecord
|
||||
} catch [System.UnauthorizedAccessException] {
|
||||
Write-Warning $psitem.Exception.Message
|
||||
if ($_.Exception -and -not [string]::IsNullOrWhiteSpace($_.Exception.Message)) {
|
||||
Write-Warning $_.Exception.Message
|
||||
} else {
|
||||
Write-Warning "Unauthorized access while setting $Path\$Name"
|
||||
}
|
||||
} catch {
|
||||
Write-Warning "Unable to set $Name due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
if ($_.Exception) {
|
||||
if (-not [string]::IsNullOrWhiteSpace($_.Exception.Message)) {
|
||||
Write-Warning $_.Exception.Message
|
||||
}
|
||||
if (-not [string]::IsNullOrWhiteSpace($_.Exception.StackTrace)) {
|
||||
Write-Warning $_.Exception.StackTrace
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user