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

Log stack trace for Exceptions #12

Merged
merged 4 commits into from
Oct 27, 2023
Merged

Conversation

vvijayaraman0822
Copy link
Contributor

Motivation

Logging the stack trace for an exception is important because it helps in troubleshooting and debugging the root cause of the problem. It identifies the point where the error occurred, the method that threw the error, and the execution sequence that led to the error.

ex.getMessage() will not have context in exceptions such as NullPointerException and StackOverflowError. These are exceptions with no messages.

Proposed Changes

  • Introduced a method in CommonUtils named getStackTrace that accepts a Throwable and returns the stack trace. This method is invoked in all the places we want to log an exception.

Test Plan

  • Added unit tests to cover the entire class CommonUtils
  • These 2 test methods testMask_fail_safe() and getStackTrace_whenExceptionThrown_shouldPrintStackTrace() assert that when an exception occurs, stack trace is printed.
  • Existing unit tests pass.
  • mvn clean install is success for all modules.

Screenshots:

Difference between previous and current logging
Screenshot 2023-10-27 at 12 12 48 PM

Build success
Screenshot 2023-10-27 at 12 28 02 PM

Copy link
Collaborator

@prasanthkv prasanthkv left a comment

Choose a reason for hiding this comment

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

LGTM

@prasanthkv prasanthkv merged commit 6cc1c44 into eBay:master Oct 27, 2023
1 check passed
@vvijayaraman0822 vvijayaraman0822 mentioned this pull request Oct 27, 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.

2 participants