scala / pickling

Fast, customizable, boilerplate-free pickling support for Scala
lampwww.epfl.ch/~hmiller/pickling
BSD 3-Clause "New" or "Revised" License
831 stars 79 forks source link

Shorter error messages #274

Open dwalend opened 9 years ago

dwalend commented 9 years ago

The full text of the pickled string is scrolling by when something goes wrong. (Will figure out what in a bit.) It's scrolling passed the limits of my shell buffer. This could also cause trouble in logs or if the exception message has to be transmitted.

Is there a good way to truncate the error message?

Thanks,

Dave

[info]     {
[info]     "tpe": "scala.Tuple3[java.lang.String,java.lang.String,scala.Int]",
[info]     "_1": "vince.kaminski@enron.com",
[info]     "_2": "susan.skarness@enron.com",
[info]     "_3": 1
[info]   }
[info]   ]
[info] })" as JSON
[info]   at scala.pickling.json.JSONPickleFormat.createReader(JSONPickleFormat.scala:31)
[info]   at scala.pickling.json.JSONPickleFormat.createReader(JSONPickleFormat.scala:23)
[info]   at net.walend.graph.semiring.EnronTest$$anonfun$1.apply$mcV$sp(EnronTest.scala:20)
[info]   at net.walend.graph.semiring.EnronTest$$anonfun$1.apply(EnronTest.scala:17)
[info]   at net.walend.graph.semiring.EnronTest$$anonfun$1.apply(EnronTest.scala:17)
[info]   at org.scalatest.Transformer$$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)
[info]   at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
[info]   at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
[info]   at org.scalatest.Transformer.apply(Transformer.scala:22)
[info]   at org.scalatest.Transformer.apply(Transformer.scala:20)
havocp commented 9 years ago

What about putting the JSON on one really long line (take the newlines out?) does that help?

It could be impossible to diagnose a problem without having the text (if the problem is in the truncated part).

dwalend commented 9 years ago

How about putting the full JSON string in the Exception, as a member, instead of in the message? That wouldn't help with transmission, but would help with diagnosing problems and reduce clutter.

Bonus points if the parser can tell us "scala.pickling.PicklingException: failed to parse near 'as JSON' " message. (The JSONPickle's toString gives the default JSONPickle, and has an "as JSON" at the end. value has a version without the boilerplate.)

An aside -- it's pretty clear that the JSONPickle is JSON. No need to put the "as JSON" bits on the end.

retronym commented 9 years ago

BTW, echoing the input data (truncated or otherwise) in the exception message might be seen as a security weakness. See http://cwe.mitre.org/data/definitions/209.html