-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abhi132004 patch 3 #45
Abhi132004 patch 3 #45
Conversation
Update GrpcCmd.java
…Cmd.java Co-authored-by: Gayal Dassanayake <[email protected]>
…Cmd.java Co-authored-by: Gayal Dassanayake <[email protected]>
…Cmd.java Co-authored-by: Gayal Dassanayake <[email protected]>
Update GrpcCmd.java
} | ||
generateBalFile(protoPath); | ||
} | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if we do a catch here, the error is logged elsewhere and also printed to the stdout. The exception is not thrown to here. Hence, this catch will not be able to catch it. We need to remove the log with the stacktrace and display a reason for the failure if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch (Exception e) {
// Handle the exception and print a user-friendly error message
handleException(e);
}
}
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());
}
In this modified code, the catch block in the execute method calls a handleException method, which you can customize to log the exception, print an error message, or suppress the stack trace as needed. This allows you to have control over how the exception is handled without the default stack trace logging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Abhi132004. It seems you have not understood what I meant in my comment. Let me try and explaing a bit more. The issue is related to the generateBalFile
method. In this method, when there are errors in the descriptor generator phase, they are caught as a CodeGeneratorException
in here [1]. However, we have only printed a generic error and the error message. But this prints stack traces as well. What we need to do is to check if we can add any error information to this printed error and try and stop the stack trace printing in the cmd.
[1]
protoc-tools/protoc-cli/src/main/java/io/ballerina/protoc/protobuf/cmd/GrpcCmd.java
Line 265 in 6db60af
} catch (CodeGeneratorException e) { |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #45 +/- ##
============================================
+ Coverage 86.42% 86.58% +0.16%
Complexity 706 706
============================================
Files 56 56
Lines 3197 3191 -6
Branches 355 355
============================================
Hits 2763 2763
+ Misses 329 323 -6
Partials 105 105 ☔ View full report in Codecov by Sentry. |
|
@dilanSachi @daneshk if all the things are okay can I fill the google form? |
protoc-cli/src/main/java/io/ballerina/protoc/protobuf/cmd/GrpcCmd.java
Outdated
Show resolved
Hide resolved
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
Closed PR due to inactivity for more than 18 days. |
To provide better error messages when the grpc command crashes, I have also considered improving the error handling within the ''generateBalFile'' method and other relevant methods in the same Java file. Look for any potential exceptions that may occur during protocol buffer processing and handle them appropriately by providing informative error messages.
Isse: ballerina-platform/ballerina-library#4656
Checklist