From 57de1bf979e537c704c468e30b5a0c4614e731ac Mon Sep 17 00:00:00 2001 From: stargateprovider Date: Mon, 8 Nov 2021 23:51:07 +0200 Subject: [PATCH] Added basic notifications to the user For when exceptions occur when communicating with the ID-card --- .../mobileauthapp/auth/AuthAppException.kt | 10 ++++++++++ .../mobileauthapp/auth/InvalidCANException.kt | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/auth/AuthAppException.kt create mode 100644 MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/auth/InvalidCANException.kt diff --git a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/auth/AuthAppException.kt b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/auth/AuthAppException.kt new file mode 100644 index 0000000..96b05d5 --- /dev/null +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/auth/AuthAppException.kt @@ -0,0 +1,10 @@ +package com.tarkvaraprojekt.mobileauthapp.auth + +/** + * A specialised RuntimeException class for exceptions related to the mobile authentication app. + * Possible error codes can be found at + * https://github.com/TanelOrumaa/Estonian-ID-card-mobile-authenticator-POC/wiki/Error-codes + * @param message Error message + * @param code An error code defined in the project wiki + */ +open class AuthAppException(message: String, var code: Int) : RuntimeException(message) \ No newline at end of file diff --git a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/auth/InvalidCANException.kt b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/auth/InvalidCANException.kt new file mode 100644 index 0000000..073c790 --- /dev/null +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/auth/InvalidCANException.kt @@ -0,0 +1,7 @@ +package com.tarkvaraprojekt.mobileauthapp.auth + +/** + * An AuthAppException for when the user entered CAN does not match the one read from the ID-card + * @see AuthAppException + */ +class InvalidCANException : AuthAppException("Invalid CAN", 400) \ No newline at end of file