diff --git a/utbot-spring-commons/src/main/kotlin/org/utbot/spring/repositoryWrapper/RepositoryWrapperInvocationHandler.kt b/utbot-spring-commons/src/main/kotlin/org/utbot/spring/repositoryWrapper/RepositoryWrapperInvocationHandler.kt index 4b47e94216..37dea711b2 100644 --- a/utbot-spring-commons/src/main/kotlin/org/utbot/spring/repositoryWrapper/RepositoryWrapperInvocationHandler.kt +++ b/utbot-spring-commons/src/main/kotlin/org/utbot/spring/repositoryWrapper/RepositoryWrapperInvocationHandler.kt @@ -2,6 +2,7 @@ package org.utbot.spring.repositoryWrapper import org.utbot.spring.api.repositoryWrapper.RepositoryInteraction import java.lang.reflect.InvocationHandler +import java.lang.reflect.InvocationTargetException import java.lang.reflect.Method class RepositoryWrapperInvocationHandler( @@ -10,7 +11,11 @@ class RepositoryWrapperInvocationHandler( ) : InvocationHandler { override fun invoke(proxy: Any, method: Method, args: Array?): Any? { val nonNullArgs = args ?: emptyArray() - val result = runCatching { method.invoke(originalRepository, *nonNullArgs) } + val result = try { + Result.success(method.invoke(originalRepository, *nonNullArgs)) + } catch (e: InvocationTargetException) { + Result.failure(e.targetException) + } RepositoryInteraction.recordedInteractions.add( RepositoryInteraction(beanName, method, nonNullArgs.toList(), result) )