Skip to content

Commit

Permalink
Improve logging for PinState.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Apr 23, 2020
1 parent 4bdcaa7 commit 208275b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/src/main/java/org/thoughtcrime/securesms/pin/PinState.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,13 @@ private static void resetPinRetryCount(@NonNull Context context, @Nullable Strin
}
}

throw new IllegalStateException("Expected: " + Arrays.toString(allowed) + ", Actual: " + currentState);
switch (currentState) {
case NO_REGISTRATION_LOCK: throw new InvalidState_NoRegistrationLock();
case REGISTRATION_LOCK_V1: throw new InvalidState_RegistrationLockV1();
case PIN_WITH_REGISTRATION_LOCK_ENABLED: throw new InvalidState_PinWithRegistrationLockEnabled();
case PIN_WITH_REGISTRATION_LOCK_DISABLED: throw new InvalidState_PinWithRegistrationLockDisabled();
default: throw new IllegalStateException("Expected: " + Arrays.toString(allowed) + ", Actual: " + currentState);
}
}

private static @NonNull State getState() {
Expand Down Expand Up @@ -428,4 +434,9 @@ private static class InvalidInferredStateError extends Error {
super(message);
}
}

private static class InvalidState_NoRegistrationLock extends IllegalStateException {}
private static class InvalidState_RegistrationLockV1 extends IllegalStateException {}
private static class InvalidState_PinWithRegistrationLockEnabled extends IllegalStateException {}
private static class InvalidState_PinWithRegistrationLockDisabled extends IllegalStateException {}
}

0 comments on commit 208275b

Please sign in to comment.