forked from mosip/tuvali
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#52): pass exception as it is to exception handler instead of wr…
…apping it with unknown
- Loading branch information
1 parent
5ac8c45
commit e30b2f1
Showing
1 changed file
with
3 additions
and
4 deletions.
There are no files selected for viewing
7 changes: 3 additions & 4 deletions
7
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
package io.mosip.tuvali.common.safeExecute | ||
|
||
import io.mosip.tuvali.openid4vpble.exception.OpenIdBLEExceptionHandler | ||
import io.mosip.tuvali.openid4vpble.exception.UnknownException | ||
|
||
class TryExecuteSync(private val bleExceptionHandler: OpenIdBLEExceptionHandler) { | ||
private val mutex = Object() | ||
|
||
fun <T> run(fn: () -> T): T? { | ||
var returnValue: T? = null; | ||
var returnValue: T? = null | ||
|
||
synchronized(mutex) { | ||
try { | ||
returnValue = fn() | ||
} catch (e: Exception) { | ||
bleExceptionHandler.handleException(UnknownException("Caught unknown exception in Try Execute", e)) | ||
bleExceptionHandler.handleException(e) | ||
} | ||
} | ||
|
||
return returnValue; | ||
return returnValue | ||
} | ||
} |