Skip to content

Commit

Permalink
add extension function Logging.handleExceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
paulchen committed Dec 9, 2023
1 parent c900735 commit cda0eac
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/kotlin/at/rueckgr/kotlin/rocketbot/util/Logging.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ fun Logging.logExceptions(lambda: Logging.() -> Any) {
logger().error("Exception occurred", e)
}
}

fun Logging.handleExceptions(function: () -> Unit) {
try {
function.invoke()
}
catch (e: Throwable) {
logger().error("Exception occurred: ", e)
}
}

0 comments on commit cda0eac

Please sign in to comment.