changes to login error handling.

throw capi error if retval not 1 or -2.

exit from program if login/capi error thrown.
This commit is contained in:
onyx-and-iris
2022-10-30 19:10:17 +00:00
parent 8c20c58085
commit 6cc43fa553
2 changed files with 5 additions and 6 deletions

View File

@@ -41,10 +41,11 @@ function Login {
elseif ($retval -eq -2) {
throw [LoginError]::new('Login may only be called once per session')
}
else { exit }
else { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
}
catch [LoginError], [CAPIError] {
Write-Warning $_.Exception.ErrorMessage()
exit
}
while (P_Dirty -or M_Dirty) { Start-Sleep -m 1 }