Add ReaderException.setStackTrace

This commit is contained in:
Sean Owen 2022-01-12 14:18:32 -06:00
parent ab23778d4b
commit b30da44d01

View file

@ -26,7 +26,7 @@ package com.google.zxing;
public abstract class ReaderException extends Exception {
// disable stack traces when not running inside test units
protected static final boolean isStackTrace =
protected static boolean isStackTrace =
System.getProperty("surefire.test.class.path") != null;
protected static final StackTraceElement[] NO_TRACE = new StackTraceElement[0];
@ -44,4 +44,15 @@ public abstract class ReaderException extends Exception {
return null;
}
/**
* For testing only. Controls whether library exception classes include stack traces or not.
* Defaults to false, unless running in the project's unit testing harness.
*
* @param enabled if true, enables stack traces in library exception classes
* @since 3.5.0
*/
public static void setStackTrace(boolean enabled) {
isStackTrace = enabled;
}
}