-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from tw-mosip/add-error-code
Add error code to OnError Event
- Loading branch information
Showing
45 changed files
with
312 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
android/src/main/java/io/mosip/tuvali/ble/exception/CentralStateHandlerException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.mosip.tuvali.ble.exception | ||
|
||
import io.mosip.tuvali.exception.BLEException | ||
import io.mosip.tuvali.exception.ErrorCode | ||
|
||
class CentralStateHandlerException(message: String, cause: Exception): BLEException(message, cause, | ||
ErrorCode.CentralStateHandlerException | ||
) |
8 changes: 8 additions & 0 deletions
8
android/src/main/java/io/mosip/tuvali/ble/exception/PeripheralStateHandlerException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.mosip.tuvali.ble.exception | ||
|
||
import io.mosip.tuvali.exception.BLEException | ||
import io.mosip.tuvali.exception.ErrorCode | ||
|
||
class PeripheralStateHandlerException(message: String, cause: Exception): BLEException(message, cause, | ||
ErrorCode.PeripheralStateHandlerException | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
android/src/main/java/io/mosip/tuvali/common/safeExecute/TryExecuteSync.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
android/src/main/java/io/mosip/tuvali/exception/BLEException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package io.mosip.tuvali.exception | ||
|
||
open class BLEException(message: String, cause: Exception?, val errorCode: ErrorCode): RuntimeException(message, cause) { | ||
} |
29 changes: 29 additions & 0 deletions
29
android/src/main/java/io/mosip/tuvali/exception/ErrorCode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.mosip.tuvali.exception | ||
|
||
// Error Code format | ||
// <Component(2)+Role(1)>(3char)_<Stage>(3char)_<Number>(3char) Eg: TVW-CON-001 | ||
// Stage --> CON(Connection) | KEX(Key Exchange) | ENC(Encryption) | TRA(Transfer) | REP(Report) | DEC(Decryption) | ||
// Component+ROLE --> TVW(Tuvali+Wallet) | TVV(Tuvali+Verifier) | TUV(Tuvali where role is unknown) | ||
// UNK --> If stage is not known | ||
|
||
enum class ErrorCode(val code: String) { | ||
UnknownException("TUV_UNK_001"), | ||
|
||
WalletUnknownException("TVW_UNK_001"), | ||
CentralStateHandlerException("TVW_UNK_002"), | ||
WalletTransferHandlerException("TVW_UNK_003"), | ||
|
||
VerifierUnknownException("TVV_UNK_001"), | ||
PeripheralStateHandlerException("TVV_UNK_002"), | ||
VerifierTransferHandlerException("TVV_UNK_003"), | ||
|
||
MTUNegotiationException("TVW_CON_001"), | ||
//TODO: Create specific error codes for the below exception | ||
TransferFailedException("TVW_REP_001"), | ||
|
||
UnsupportedMTUSizeException("TVV_CON_001"), | ||
CorruptedChunkReceivedException("TVV_TRA_001"), | ||
TooManyFailureChunksException("TVV_TRA_002"), | ||
} | ||
|
||
|
13 changes: 13 additions & 0 deletions
13
android/src/main/java/io/mosip/tuvali/exception/ExceptionUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.mosip.tuvali.exception | ||
|
||
class ExceptionUtils { | ||
companion object { | ||
fun getRootBLECause(e: BLEException): BLEException { | ||
var cause: BLEException = e | ||
while (cause.cause != null && cause.cause is BLEException) { | ||
cause = cause.cause as BLEException | ||
} | ||
return cause | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
android/src/main/java/io/mosip/tuvali/exception/UnknownException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package io.mosip.tuvali.exception | ||
|
||
class UnknownException(message: String, cause: Exception): BLEException(message, cause, ErrorCode.UnknownException) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
android/src/main/java/io/mosip/tuvali/exception/handlers/VerifierExceptionHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.mosip.tuvali.exception.handlers | ||
|
||
import android.util.Log | ||
import io.mosip.tuvali.exception.ErrorCode | ||
import io.mosip.tuvali.exception.ExceptionUtils | ||
import io.mosip.tuvali.transfer.Util | ||
import io.mosip.tuvali.verifier.exception.VerifierException | ||
|
||
class VerifierExceptionHandler(val sendError: (String, ErrorCode) -> Unit) { | ||
private val logTag = Util.getLogTag(javaClass.simpleName) | ||
|
||
fun handleException(e: VerifierException){ | ||
val rootCause = ExceptionUtils.getRootBLECause(e) | ||
|
||
Log.e(logTag, "Handling Verifier Exception: ", e) | ||
sendError(e.message ?: "Something went wrong in Verifier: $rootCause", rootCause.errorCode) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
android/src/main/java/io/mosip/tuvali/exception/handlers/WalletExceptionHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.mosip.tuvali.exception.handlers | ||
|
||
import android.util.Log | ||
import io.mosip.tuvali.exception.ErrorCode | ||
import io.mosip.tuvali.exception.ExceptionUtils | ||
import io.mosip.tuvali.transfer.Util | ||
import io.mosip.tuvali.wallet.exception.WalletException | ||
|
||
class WalletExceptionHandler(val sendError: (String, ErrorCode) -> Unit) { | ||
private val logTag = Util.getLogTag(javaClass.simpleName) | ||
|
||
fun handleException(e: WalletException) { | ||
val rootCause = ExceptionUtils.getRootBLECause(e) | ||
|
||
Log.e(logTag, "Handling Wallet Exception: ", e) | ||
sendError(e.message ?: "Something went wrong in Wallet: $rootCause", rootCause.errorCode) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
android/src/main/java/io/mosip/tuvali/openid4vpble/exception/StateHandlerException.kt
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
android/src/main/java/io/mosip/tuvali/openid4vpble/exception/TransferHandlerException.kt
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
android/src/main/java/io/mosip/tuvali/openid4vpble/exception/UnknownException.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 8 additions & 3 deletions
11
android/src/main/java/io/mosip/tuvali/verifier/exception/CorruptedChunkReceivedException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
package io.mosip.tuvali.verifier.exception | ||
|
||
class CorruptedChunkReceivedException(size: Int, receivedSeqNumber: Int, receivedMtuSize: Int) : VerifierException( | ||
"size: $size, receivedSeqNumber: $receivedSeqNumber, receivedMtuSize: $receivedMtuSize" | ||
) {} | ||
import io.mosip.tuvali.exception.BLEException | ||
import io.mosip.tuvali.exception.ErrorCode | ||
|
||
class CorruptedChunkReceivedException(size: Int, receivedSeqNumber: Int, receivedMtuSize: Int) : BLEException( | ||
"size: $size, receivedSeqNumber: $receivedSeqNumber, receivedMtuSize: $receivedMtuSize", | ||
null, | ||
ErrorCode.CorruptedChunkReceivedException | ||
) |
4 changes: 0 additions & 4 deletions
4
android/src/main/java/io/mosip/tuvali/verifier/exception/ReadFromRemoteException.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.