Skip to content

Commit

Permalink
feat(#52): pass exception as it is to exception handler instead of wr…
Browse files Browse the repository at this point in the history
…apping it with unknown
  • Loading branch information
tilak-puli committed Apr 20, 2023
1 parent 5ac8c45 commit e30b2f1
Showing 1 changed file with 3 additions and 4 deletions.
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
}
}

0 comments on commit e30b2f1

Please sign in to comment.