Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Joni's fix for JsonBoxSerializer

  • Loading branch information...
commit a68b65d3920b998ff412ba90f1608d75f4328387 1 parent 12885f6
@nafg nafg authored
View
16 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,11 +57,6 @@ 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)) ::
@@ -67,6 +64,11 @@ class JsonBoxSerializer extends Serializer[Box[_]] {
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 {
Please sign in to comment.
Something went wrong with that request. Please try again.