eJMask is a JVM-based masking library that provides an easy-to-use API for masking sensitive data in your Java applications. With eJMask, you can quickly mask sensitive information like personal information, credit card numbers, and more.
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.
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 asNullPointerException
andStackOverflowError
. These are exceptions with no messages.Proposed Changes
CommonUtils
namedgetStackTrace
that accepts aThrowable
and returns the stack trace. This method is invoked in all the places we want to log an exception.Test Plan
CommonUtils
testMask_fail_safe()
andgetStackTrace_whenExceptionThrown_shouldPrintStackTrace()
assert that when an exception occurs, stack trace is printed.mvn clean install
is success for all modules.Screenshots:
Difference between previous and current logging
Build success