polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [3/5] polygene-java git commit: Better exception message when failing to guess deserialization of Object
Date Mon, 03 Apr 2017 08:09:39 GMT
Better exception message when failing to guess deserialization of Object

POLYGENE-231


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/41402490
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/41402490
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/41402490

Branch: refs/heads/develop
Commit: 41402490a1d7bee058d9acb51600511be7285873
Parents: b4b6396
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Mon Apr 3 10:08:19 2017 +0200
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Mon Apr 3 10:08:19 2017 +0200

----------------------------------------------------------------------
 .../serialization/javaxjson/JavaxJsonDeserializer.java   | 10 +++++++++-
 .../serialization/javaxxml/JavaxXmlDeserializer.java     |  9 ++++++++-
 .../messagepack/MessagePackDeserializer.java             | 11 ++++++++++-
 3 files changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/41402490/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonDeserializer.java
b/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonDeserializer.java
index d1310d7..06bb8c8 100644
--- a/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonDeserializer.java
+++ b/core/spi/src/main/java/org/apache/polygene/serialization/javaxjson/JavaxJsonDeserializer.java
@@ -255,7 +255,15 @@ public class JavaxJsonDeserializer extends AbstractTextDeserializer
                 }
             case STRING:
                 byte[] bytes = Base64.getDecoder().decode( asString( json ).getBytes( UTF_8
) );
-                return (T) deserializeJava( bytes );
+                try
+                {
+                    return (T) deserializeJava( bytes );
+                }
+                catch( SerializationException ex )
+                {
+                    throw new SerializationException( "Don't know how to deserialize " +
valueType + " from " + json,
+                                                      ex );
+                }
             default:
                 throw new SerializationException( "Don't know how to deserialize " + valueType
+ " from " + json );
         }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/41402490/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlDeserializer.java
b/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlDeserializer.java
index 69a9068..dcadbd1 100644
--- a/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlDeserializer.java
+++ b/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlDeserializer.java
@@ -359,7 +359,14 @@ public class JavaxXmlDeserializer extends AbstractTextDeserializer
         if( xml.getNodeType() == Node.CDATA_SECTION_NODE || xml.getNodeType() == Node.TEXT_NODE
)
         {
             byte[] bytes = Base64.getDecoder().decode( xml.getNodeValue().getBytes( UTF_8
) );
-            return deserializeJava( bytes );
+            try
+            {
+                return deserializeJava( bytes );
+            }
+            catch( SerializationException ex )
+            {
+                throw new SerializationException( "Don't know how to deserialize " + valueType
+ " from " + xml, ex );
+            }
         }
         throw new SerializationException( "Don't know how to deserialize " + valueType +
" from " + xml );
     }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/41402490/extensions/serialization-messagepack/src/main/java/org/apache/polygene/serialization/messagepack/MessagePackDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/serialization-messagepack/src/main/java/org/apache/polygene/serialization/messagepack/MessagePackDeserializer.java
b/extensions/serialization-messagepack/src/main/java/org/apache/polygene/serialization/messagepack/MessagePackDeserializer.java
index 402f9bc..d74b0a4 100644
--- a/extensions/serialization-messagepack/src/main/java/org/apache/polygene/serialization/messagepack/MessagePackDeserializer.java
+++ b/extensions/serialization-messagepack/src/main/java/org/apache/polygene/serialization/messagepack/MessagePackDeserializer.java
@@ -282,7 +282,16 @@ public interface MessagePackDeserializer extends Deserializer
             switch( value.getValueType() )
             {
                 case BINARY:
-                    return deserializeJava( value.asBinaryValue().asByteArray() );
+                    try
+                    {
+                        return deserializeJava( value.asBinaryValue().asByteArray() );
+                    }
+                    catch( SerializationException ex )
+                    {
+                        throw new SerializationException( "Don't know how to deserialize
" + valueType
+                                                          + " from " + value + " (" + value.getValueType()
+ ")",
+                                                          ex );
+                    }
                 case MAP:
                     MapValue mapValue = value.asMapValue();
                     Optional<String> typeInfo = mapValue


Mime
View raw message