{"record":{"id":"4cedf67a1068664d","repo":"quarkusio/quarkus","slug":"e-getmessage-rethrow-of-code-generation-failure","errorCode":null,"errorMessage":"e.getMessage() (rethrow of code generation failure)","messagePattern":"e\\.getMessage\\(\\) \\(rethrow of code generation failure\\)","errorType":"exception","errorClass":"CodeGenException","httpStatus":null,"severity":"error","filePath":"extensions/grpc/codegen/src/main/java/io/quarkus/grpc/codegen/GrpcCodeGen.java","lineNumber":436,"sourceCode":"                                throw new GrpcCodeGenException(\"Failed to create directory: \" + protoOutputDir, e);\n                            }\n                            Path outPath = protoOutputDir.resolve(strippedPathStr);\n                            try {\n                                Files.createDirectories(outPath.getParent());\n                                if (isDependency) {\n                                    copySanitizedProtoFile(artifact, path, outPath);\n                                } else {\n                                    Files.copy(path, outPath, StandardCopyOption.REPLACE_EXISTING);\n                                }\n                                protoFiles.add(outPath);\n                            } catch (IOException e) {\n                                throw new GrpcCodeGenException(\"Failed to extract proto file\" + path + \" to target: \"\n                                        + outPath, e);\n                            }\n                        }\n                    });\n        } catch (GrpcCodeGenException e) {\n            throw new CodeGenException(e.getMessage(), e);\n        }\n    }\n\n    private static String stripProtoPrefix(String relativePathStr) {\n        if (relativePathStr.startsWith(SRC_MAIN_PROTO_DIR)) {\n            return relativePathStr.substring(SRC_MAIN_PROTO_DIR.length());\n        }\n        if (relativePathStr.startsWith(SRC_TEST_PROTO_DIR)) {\n            return relativePathStr.substring(SRC_TEST_PROTO_DIR.length());\n        }\n        if (relativePathStr.startsWith(PROTO_DIR)) {\n            return relativePathStr.substring(PROTO_DIR.length());\n        }\n        return relativePathStr;\n    }\n\n    private static Path getProtoOutputDir(Path workDir, ResolvedDependency artifact) {\n        String uniqueName = artifact.getGroupId() + \":\" + artifact.getArtifactId();","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/grpc/codegen/src/main/java/io/quarkus/grpc/codegen/GrpcCodeGen.java#L418-L454","documentation":"extractProtosFromArtifact catches its own GrpcCodeGenException and rethrows it as a generic io.quarkus.deployment.CodeGenException with the same message, preserving the cause. This is the wrapping boundary developers actually see in build logs; the root message will be one of the more specific 'Failed to create directory' or 'Failed to extract proto file' errors.","triggerScenarios":"Any failure inside proto extraction (directory creation or file copy during scanning of dependency protos) surfaces as this CodeGenException during the generate-code phase of quarkus:dev, mvn compile, or a Quarkus build.","commonSituations":"Same underlying causes as the wrapped errors: unwritable build directory, locked or corrupted dependency JARs, disk space, long Windows paths — plus confusing stack traces where the top-level CodeGenException hides the IO detail.","solutions":["Read the caused-by chain: the root GrpcCodeGenException/IOException names the real problem (permissions, missing file, disk)","Run mvn clean / gradle clean and rebuild to clear stale generated output","Fix the underlying IO condition (writable target dir, intact artifact JAR) rather than the CodeGenException itself","If it reproduces on a good checkout, pin/refresh the dependency containing the proto files"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    quarkusBuild.perform();\n} catch (CodeGenException e) {\n    // always inspect the cause chain — this exception wraps a GrpcCodeGenException/IOException\n    Throwable root = e;\n    while (root.getCause() != null) root = root.getCause();\n    log.error(\"gRPC codegen failed, root cause: \" + root.getMessage(), e);\n}","preventionTips":["Read the full stack trace, not just the top-level CodeGenException message","Reproduce with a clean checkout before blaming environment","Keep Quarkus and platform BOM versions aligned"],"tags":["build","grpc","codegen","wrapped-exception"],"backgroundTag":"code-generation-failed","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"}