Skip to content

Commit

Permalink
Update GrpcCmd.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhi132004 authored Nov 6, 2023
1 parent 62bbb57 commit 2637b4d
Showing 1 changed file with 1 addition and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,41 +158,7 @@ public void execute() {
// You can choose to log, print, or handle them differently
outStream.println("Unexpected Error: " + e.getMessage());

Check warning on line 159 in protoc-cli/src/main/java/io/ballerina/protoc/protobuf/cmd/GrpcCmd.java

View check run for this annotation

Codecov / codecov/patch

protoc-cli/src/main/java/io/ballerina/protoc/protobuf/cmd/GrpcCmd.java#L159

Added line #L159 was not covered by tests
}
}
private void generateBalFile(String protoFile) {
try {
// Your code to generate .bal file from the proto file

// If an error occurs during the descriptor generator phase, throw a CodeGeneratorException with a descriptive message.
if (errorOccurred) {
throw new CodeGeneratorException("An error occurred during code generation. Additional information here.");
}

// Rest of the code for successful generation
} catch (CodeGeneratorException e) {
// Handle CodeGeneratorException without printing stack traces
String errorMessage = "Code Generation Error: " + e.getMessage();
LOG.error(errorMessage);
outStream.println(errorMessage);
} catch (IOException e) {
// Handle IO Exception
String errorMessage = "IO Error: " + e.getMessage();
LOG.error(errorMessage);
outStream.println(errorMessage);
} catch (Exception e) {
// Handle unexpected exceptions
String errorMessage = "Unexpected Error: " + e.getMessage();
LOG.error(errorMessage, e);
outStream.println(errorMessage);
}
}

private void handleException(Exception e) {
// Log the exception or print a user-friendly error message
// If you want to suppress the stack trace, you can just print a custom error message here
outStream.println("Error: " + e.getMessage());
}

}
private List<String> getProtoFiles(String path) throws IOException {
if (path.endsWith("**.proto")) {
try (Stream<Path> walk = Files.walk(Paths.get(path.substring(0, path.length() - 8)))) {
Expand Down

0 comments on commit 2637b4d

Please sign in to comment.