Skip to content

Commit a8eb748

Browse files
committed
Remove usage of UndeclaredThrowableException
1 parent 020abdd commit a8eb748

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/main/kotlin/graphql/kickstart/tools/resolver/MethodFieldResolver.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal class MethodFieldResolver(
3030
field: FieldDefinition,
3131
search: FieldResolverScanner.Search,
3232
options: SchemaParserOptions,
33-
val method: Method
33+
val method: Method,
3434
) : FieldResolver(field, search, options, search.type) {
3535

3636
private val log = LoggerFactory.getLogger(javaClass)
@@ -187,7 +187,7 @@ internal open class MethodFieldResolverDataFetcher(
187187
private val sourceResolver: SourceResolver,
188188
method: Method,
189189
private val args: List<ArgumentPlaceholder>,
190-
private val options: SchemaParserOptions
190+
private val options: SchemaParserOptions,
191191
) : DataFetcher<Any> {
192192

193193
private val resolverMethod = method
@@ -242,7 +242,7 @@ internal class TrivialMethodFieldResolverDataFetcher(
242242
sourceResolver: SourceResolver,
243243
method: Method,
244244
args: List<ArgumentPlaceholder>,
245-
options: SchemaParserOptions
245+
options: SchemaParserOptions,
246246
) : MethodFieldResolverDataFetcher(sourceResolver, method, args, options),
247247
TrivialDataFetcher<Any> // just to mark it for tracing and optimizations
248248

@@ -256,11 +256,7 @@ private fun invoke(method: Method, instance: Any, args: Array<Any?>): Any? {
256256
try {
257257
return method.invoke(instance, *args)
258258
} catch (invocationException: InvocationTargetException) {
259-
when (val e = invocationException.cause) {
260-
is RuntimeException -> throw e
261-
is Error -> throw e
262-
else -> throw e ?: RuntimeException("Unknown error occurred while invoking resolver method")
263-
}
259+
throw invocationException.cause ?: RuntimeException("Unknown error occurred while invoking resolver method")
264260
}
265261
}
266262

0 commit comments

Comments
 (0)