I have two functions that invoke a code block with a try-catch like:
fun <R: Any> executeRestCall( block: () -> R ): R { try { return block() } catch (ex: RestClientException) { throw IllegalArgumentException(ex.message) } } fun <R: Any> executeProcessCall( block: () -> R ): R { try { return block() } catch (ex: RuntimeException) { throw IllegalStateException(ex.message) } } I need to parametrize required exception. How can this function be refactored?
try-catchblockblock()without ever using these methods, then delete these methods :D