{"record":{"id":"14085a38a545aa84","repo":"quarkusio/quarkus","slug":"method-targetmethod-name-of-class-targetm","errorCode":null,"errorMessage":"Method '${targetMethod.name()} of class '${targetMethod.declaringClass().name()}' cannot be used as an exception mapper as it does not declare 'Response' or 'Uni<Response>' or as its return type","messagePattern":"Method '(.+?) of class '(.+?)' cannot be used as an exception mapper as it does not declare 'Response' or 'Uni<Response>' or as its return type","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/exceptionmappers/ServerExceptionMapperGenerator.java","lineNumber":634,"sourceCode":"    }\n\n    private static ReturnType determineReturnType(MethodInfo targetMethod) {\n        if (targetMethod.returnType().name().equals(RESPONSE)) {\n            return ReturnType.RESPONSE;\n        } else if (targetMethod.returnType().name().equals(REST_RESPONSE)) {\n            return ReturnType.REST_RESPONSE;\n        } else if (targetMethod.returnType().kind() == Type.Kind.PARAMETERIZED_TYPE) {\n            ParameterizedType parameterizedType = targetMethod.returnType().asParameterizedType();\n            if (parameterizedType.name().equals(UNI) && (parameterizedType.arguments().size() == 1)) {\n                if (parameterizedType.arguments().get(0).name().equals(RESPONSE)) {\n                    return ReturnType.UNI_RESPONSE;\n                }\n                if (parameterizedType.arguments().get(0).name().equals(REST_RESPONSE)) {\n                    return ReturnType.UNI_REST_RESPONSE;\n                }\n            }\n        }\n        throw new RuntimeException(\"Method '\" + targetMethod.name() + \" of class '\" + targetMethod.declaringClass().name()\n                + \"' cannot be used as an exception mapper as it does not declare 'Response' or 'Uni<Response>' or as its return type\");\n    }\n\n    private static void checkModifiers(MethodInfo info) {\n        if ((info.flags() & Modifier.PRIVATE) != 0) {\n            throw new RuntimeException(\"Method '\" + info.name() + \" of class '\" + info.declaringClass().name()\n                    + \"' cannot be private as it is annotated with '@\" + SERVER_EXCEPTION_MAPPER\n                    + \"'\");\n        }\n        if ((info.flags() & Modifier.STATIC) != 0) {\n            throw new RuntimeException(\"Method '\" + info.name() + \" of class '\" + info.declaringClass().name()\n                    + \"' cannot be static as it is annotated with '@\" + SERVER_EXCEPTION_MAPPER\n                    + \"'\");\n        }\n    }\n\n    private static String getGeneratedClassName(MethodInfo targetMethod, Type handledExceptionType) {\n        return targetMethod.declaringClass().name() + \"$ExceptionMapper$\"","sourceCodeStart":616,"sourceCodeEnd":652,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/exceptionmappers/ServerExceptionMapperGenerator.java#L616-L652","documentation":"RESTEasy Reactive's build-time generator scans methods annotated with @ServerExceptionMapper / @Provider and requires a supported return type: 'Response', 'RestResponse', 'Uni<Response>' (or Uni<RestResponse>). In determineReturnType, if no branch matches the method's return type, a RuntimeException is thrown, aborting application build. This enforces that exception mappers actually produce an HTTP response that can be returned to the client.","triggerScenarios":"Annotating a method with @ServerExceptionMapper (or @Provider recognized as a server exception mapper) whose return type is anything other than Response, RestResponse, Uni<Response>, or Uni<RestResponse> — e.g. void, String, MyPojo, CompletionStage<Response> — triggers the error during Quarkus augmentation.","commonSituations":"Developers migrating from classic JAX-RS ExceptionMapper semantics, writing a mapper that logs and returns void, returning a custom DTO instead of Response, or accidentally annotating an ordinary helper method with @Provider in a scanned package.","solutions":["Change the mapper method return type to jakarta.ws.rs.core.Response","Or return io.smallrye.mutiny.Uni<Response> for asynchronous mapping","Or return jakarta.ws.rs.core.RestResponse if using the RESTEasy Reactive API","Remove @ServerExceptionMapper/@Provider from methods that are not intended to be exception mappers"],"exampleFix":"// before\n@ServerExceptionMapper\npublic String map(IllegalStateException e) { return e.getMessage(); }\n\n// after\n@ServerExceptionMapper\npublic Response map(IllegalStateException e) { return Response.status(500).entity(e.getMessage()).build(); }","handlingStrategy":"validation","validationCode":"java.lang.reflect.Method m = ...; // the annotated mapper\nboolean ok = Response.class.equals(m.getReturnType())\n    || RestResponse.class.equals(m.getReturnType())\n    || (m.getReturnType() == Uni.class && m.getGenericReturnType() instanceof ParameterizedType pt\n        && Response.class.equals(pt.getActualTypeArguments()[0]));\nif (!ok) throw new IllegalStateException(\"Mapper must return Response, RestResponse, or Uni<Response>: \" + m);\n","typeGuard":"static boolean isValidMapperReturn(java.lang.reflect.Method m) {\n    return Response.class.equals(m.getReturnType()) || RestResponse.class.equals(m.getReturnType())\n        || (m.getReturnType() == Uni.class\n            && m.getGenericReturnType() instanceof ParameterizedType pt\n            && (Response.class.equals(pt.getActualTypeArguments()[0]) || RestResponse.class.equals(pt.getActualTypeArguments()[0])));\n}\n","tryCatchPattern":null,"preventionTips":["Always declare @ServerExceptionMapper methods to return Response or Uni<Response>","Never put @Provider on non-mapper helper methods","Let your IDE annotate only methods returning Response; add an ArchUnit/architectural test scanning mapper signatures","Run a quick mvn compile of the extension/module before pushing — the error surfaces at build time"],"tags":["quarkus","resteasy-reactive","build-time","exception-mapper"],"backgroundTag":"invalid-exception-mapper-signature","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}