Replies: 1 comment
-
@kwein123 try {
#this was run against a SQLite connection, the table does not exist and the syntax is incorrect... so an error is generated.
Invoke-SqlUpdate "select top 10 from noexist" -ErrorAction Stop
Write-Host "This should not be displayed!"
}
catch {
# $_ is an error record...
$_.exception
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
During Invoke-SqlUpdate, I want to catch an error about "Violation of UNIQUE KEY constraint" and handle it on my own. If any other error happens during Invoke-SqlUpdate, I want to let the default (whatever that is) occur.
I have tried every combination of
But I can't ever reach the catch block. I can ignore this AND OTHER errors, or I can exit the function, etc. But I want to get into the catch block - at least for this one error.
(FWIW - I can easily get that error to occur in my code)
Beta Was this translation helpful? Give feedback.
All reactions