mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-04 21:20:39 +00:00
Use pattern matching switch cases
This commit is contained in:
parent
80c1a6d2af
commit
8d55dfb66b
27 changed files with 395 additions and 380 deletions
|
@ -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, default -> 2;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue