added custom error classes

Added CAPI and Login custom error classes.

Cleaned up output when error is thrown.
This commit is contained in:
onyx-and-iris
2021-04-29 20:23:02 +01:00
parent 0af51e83b3
commit 94be34b3da
3 changed files with 111 additions and 65 deletions

25
lib/errors.ps1 Normal file
View File

@@ -0,0 +1,25 @@
class LoginError : Exception {
[String]$msg
LoginError([String]$msg) {
$this.msg = $msg
}
[String] ErrorMessage() {
return $this.msg
}
}
class CAPIError : Exception {
[Int]$retval
[String]$caller
CAPIError([Int]$retval, [String]$caller) {
$this.retval = $retval
$this.caller = $caller
}
[String] ErrorMessage() {
return "ERROR: CAPI return value: {0} in {1}" -f $this.retval, $this.caller
}
}