pretty-stacktraces
pretty-stacktraces copied to clipboard
StacktracesInspector.inspectStackTrace unconditionally prints error to stdout
If a tasty file of an incompatible version is passed to the inspectStackTrace method, the error message is uncondittionally printed to stderr. There's no way to suspend it. The method should indeed return error but it should not pollute stderr without user's knowledge.
In the case below, the "Runner.tasty" file was built with scala 3.0.2, while the script is using 3.1.0.
Repro
// using scala "3.1.0"
// using lib "org.virtuslab::pretty-stacktraces:0.0.1-M1"
import org.virtuslab.stacktraces.core.StacktracesInspector
import java.io.File
import scala.util.Try
@main def main = {
val ex = new Exception("")
val e = ex.getStackTrace.head
Try{StacktracesInspector.inspectStackTrace(e, new File("/tmp/runner_3.jar_sources3392797399715882651/scala/cli/runner/Runner.tasty"))}
}
Expected: No output
Actual: Prints
error while loading Typeable$package$,
class file scala/reflect/Typeable$package.class is broken, reading aborted with class dotty.tools.tasty.UnpickleException
TASTy signature has wrong version.
expected: {majorVersion: 28, minorVersion: 0}
found : {majorVersion: 28, minorVersion: 1}
This TASTy file was produced by a more recent, forwards incompatible release.
To read this TASTy file, please upgrade your tooling.
The TASTy file was produced by Scala 3.1.0-bin-nonbootstrapped.
error while loading Quotes$package$,
class file scala/quoted/Quotes$package.class is broken, reading aborted with class dotty.tools.tasty.UnpickleException
TASTy signature has wrong version.
expected: {majorVersion: 28, minorVersion: 0}
found : {majorVersion: 28, minorVersion: 1}
This TASTy file was produced by a more recent, forwards incompatible release.
To read this TASTy file, please upgrade your tooling.
The TASTy file was produced by Scala 3.1.0-bin-nonbootstrapped.
error while loading Expr$,
class file scala/quoted/runtime/Expr.class is broken, reading aborted with class dotty.tools.tasty.UnpickleException
TASTy signature has wrong version.
expected: {majorVersion: 28, minorVersion: 0}
found : {majorVersion: 28, minorVersion: 1}
This TASTy file was produced by a more recent, forwards incompatible release.
To read this TASTy file, please upgrade your tooling.
The TASTy file was produced by Scala 3.1.0-bin-nonbootstrapped.