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 }

View File

@ -5,12 +5,10 @@ function Setup_DLL {
if ([string]::IsNullOrWhiteSpace($vb_path)) {
throw [VMRemoteErrors]::new("ERROR: Couldn't get Voicemeeter path")
}
else {
$dll = Join-Path -Path $vb_path -ChildPath ("VoicemeeterRemote" + `
(& { if ([Environment]::Is64BitOperatingSystem) { "64" } else { "" } }) + `
".dll")
}
}
catch [VMRemoteErrors] {
Write-Warning $_.Exception.ErrorMessage()
return $false