Open mattelacchiato opened 4 years ago
Ran into this same issue. Using "com.lihaoyi" %% "pprint" % "0.7.1". Library chokes on certain strings. Had to remove use from production.
same thing here, crash in production, we are still using the lib but with a safe wrapper
object PrettyPrintHelper extends LazyLogging {
/**
* Safe wrapper around pprint.
* This method exists because of pprint not supporting some non-printable characters,
* exploding with an exception when attempting to do so.
*
* See issue: https://github.com/com-lihaoyi/PPrint/issues/35
*/
def safePrettyPrint(anyValue: Any): String = {
Try(BlackWhite.apply(anyValue).toString()).fold(err => {
logger.error(s"Failed to pretty print $anyValue with message: ${err.getMessage}", err)
anyValue.toString
}, identity)
}
}
We are using pprint in property based testing, where we create arbitrary strings. Sadly, pprint fails on some of those characters:
Message: Unknown ansi-escape at index 3 inside string cannot be parsed into an fansi.Str
Example: