Skip to content
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

Closed

Conversation

Abhi132004
Copy link

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

  • Linked to an issue
  • Updated the changelog
  • Added tests
  • Updated the spec

@Abhi132004 Abhi132004 requested a review from daneshk as a code owner October 10, 2023 17:40
}
generateBalFile(protoPath);
}
} catch (Exception e) {
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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]

Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Oct 31, 2023
Copy link

codecov bot commented Nov 1, 2023

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (6db60af) 86.42% compared to head (2637b4d) 86.58%.

Files Patch % Lines
...java/io/ballerina/protoc/protobuf/cmd/GrpcCmd.java 30.76% 7 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

@Abhi132004
Copy link
Author

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (ffbf33d) 86.42% compared to head (771f52f) 86.53%.

Additional details and impacted files
☔ View full report in Codecov by Sentry. 📢 Have feedback on the report? Share it here.

@Abhi132004 Abhi132004 closed this Nov 2, 2023
@Abhi132004 Abhi132004 reopened this Nov 2, 2023
@daneshk daneshk removed the Stale label Nov 2, 2023
@Abhi132004
Copy link
Author

@dilanSachi @daneshk if all the things are okay can I fill the google form?

Copy link

github-actions bot commented Dec 1, 2023

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Dec 1, 2023
Copy link

github-actions bot commented Dec 4, 2023

Closed PR due to inactivity for more than 18 days.

@github-actions github-actions bot closed this Dec 4, 2023
@dilanSachi dilanSachi removed the Stale label Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants