Permalink
Browse files

Joni's fix for JsonBoxSerializer

  • Loading branch information...
1 parent 12885f6 commit a68b65d3920b998ff412ba90f1608d75f4328387 @nafg nafg committed Jan 6, 2013
Showing with 9 additions and 7 deletions.
  1. +9 −7 core/json-ext/src/main/scala/net/liftweb/json/ext/JsonBoxSerializer.scala
@@ -40,12 +40,14 @@ class JsonBoxSerializer extends Serializer[Box[_]] {
extract(chain, TypeInfo(BoxClass, Some(typeHoldingFailure))).asInstanceOf[Box[Failure]])
case JObject(JField("box_failure", JString("ParamFailure")) ::
JField("msg", JString(msg)) ::
- JField("exception", exception) ::
+ JField("exception", exn) ::
JField("chain", chain) ::
JField("paramType", JString(paramType)) ::
JField("param", param) :: Nil) =>
val clazz = Thread.currentThread.getContextClassLoader.loadClass(paramType)
- ParamFailure(msg, extract(param, TypeInfo(clazz, None)))
+ ParamFailure(msg, deserializeException(exn),
+ extract(chain, TypeInfo(BoxClass, Some(typeHoldingFailure))).asInstanceOf[Box[Failure]],
+ extract(param, TypeInfo(clazz, None)))
case x =>
val t = ptype.getOrElse(throw new MappingException("parameterized type not known for Box"))
Full(extract(x, TypeInfo(t.getActualTypeArguments()(0).asInstanceOf[Class[_]], None)))
@@ -55,18 +57,18 @@ class JsonBoxSerializer extends Serializer[Box[_]] {
def serialize(implicit format: Formats): PartialFunction[Any, JValue] = {
case Full(x) => decompose(x)
case Empty => JNull
- case Failure(msg, exn, chain) =>
- JObject(JField("box_failure", JString("Failure")) ::
- JField("msg", JString(msg)) ::
- JField("exception", serializeException(exn)) ::
- JField("chain", decompose(chain)) :: Nil)
case ParamFailure(msg, exn, chain, param) =>
JObject(JField("box_failure", JString("ParamFailure")) ::
JField("msg", JString(msg)) ::
JField("exception", serializeException(exn)) ::
JField("chain", decompose(chain)) ::
JField("paramType", JString(param.asInstanceOf[AnyRef].getClass.getName)) ::
JField("param", decompose(param)) :: Nil)
+ case Failure(msg, exn, chain) =>
+ JObject(JField("box_failure", JString("Failure")) ::
+ JField("msg", JString(msg)) ::
+ JField("exception", serializeException(exn)) ::
+ JField("chain", decompose(chain)) :: Nil)
}
private val typeHoldingFailure = new ParameterizedType {

0 comments on commit a68b65d

Please sign in to comment.