X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/56ee173d03baf8feede7c14aea5d9d670a047ae7..19e9f31afdb85a76b7c1cd9a3f3fc54a842ba0a8:/src/main/java/org/asamk/signal/Main.java?ds=inline diff --git a/src/main/java/org/asamk/signal/Main.java b/src/main/java/org/asamk/signal/Main.java index 0a30d202..1e05206d 100644 --- a/src/main/java/org/asamk/signal/Main.java +++ b/src/main/java/org/asamk/signal/Main.java @@ -62,11 +62,11 @@ public class Main { } catch (CommandException e) { System.err.println(e.getMessage()); if (verboseLevel > 0 && e.getCause() != null) { - e.getCause().printStackTrace(); + e.getCause().printStackTrace(System.err); } status = getStatusForError(e); } catch (Throwable e) { - e.printStackTrace(); + e.printStackTrace(System.err); status = 2; } System.exit(status); @@ -109,18 +109,13 @@ public class Main { } private static int getStatusForError(final CommandException e) { - if (e instanceof UserErrorException) { - return 1; - } else if (e instanceof UnexpectedErrorException) { - return 2; - } else if (e instanceof IOErrorException) { - return 3; - } else if (e instanceof UntrustedKeyErrorException) { - return 4; - } else if (e instanceof RateLimitErrorException) { - return 5; - } else { - return 2; - } + return switch (e) { + case UserErrorException userErrorException -> 1; + case UnexpectedErrorException unexpectedErrorException -> 2; + case IOErrorException ioErrorException -> 3; + case UntrustedKeyErrorException untrustedKeyErrorException -> 4; + case RateLimitErrorException rateLimitErrorException -> 5; + case null -> 2; + }; } }