From 6cc43fa5539857761d2d616f7d488777145f9ce5 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Sun, 30 Oct 2022 19:10:17 +0000 Subject: [PATCH] changes to login error handling. throw capi error if retval not 1 or -2. exit from program if login/capi error thrown. --- lib/base.ps1 | 3 ++- lib/binding.ps1 | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/base.ps1 b/lib/base.ps1 index 5ec59ff..bcc5769 100644 --- a/lib/base.ps1 +++ b/lib/base.ps1 @@ -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 } diff --git a/lib/binding.ps1 b/lib/binding.ps1 index f3a3c86..99550c7 100644 --- a/lib/binding.ps1 +++ b/lib/binding.ps1 @@ -5,11 +5,9 @@ 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") - } + $dll = Join-Path -Path $vb_path -ChildPath ("VoicemeeterRemote" + ` + (& { if ([Environment]::Is64BitOperatingSystem) { "64" } else { "" } }) + ` + ".dll") } catch [VMRemoteErrors] { Write-Warning $_.Exception.ErrorMessage()