ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptupit...@apache.org
Subject [08/33] ignite git commit: IGNITE-4131 .NET: Improve "Unsupported type exception" with additional information
Date Mon, 14 Nov 2016 09:26:20 GMT
IGNITE-4131 .NET: Improve "Unsupported type exception" with additional information


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6a2ecdbf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6a2ecdbf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6a2ecdbf

Branch: refs/heads/master
Commit: 6a2ecdbf5dbc86ff0c25cca579a669e90b3cfffd
Parents: a801f01
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Fri Oct 28 19:45:29 2016 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Fri Oct 28 19:45:29 2016 +0300

----------------------------------------------------------------------
 .../Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs       | 12 ++++++++++++
 .../Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs      |  6 +++---
 2 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6a2ecdbf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
index 860fd9e..cc5d8a1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
@@ -1949,6 +1949,18 @@ namespace Apache.Ignite.Core.Impl.Binary
         }
 
         /// <summary>
+        /// Gets the unsupported type exception.
+        /// </summary>
+        public static BinaryObjectException GetUnsupportedTypeException(Type type, object
obj)
+        {
+            return new BinaryObjectException(string.Format(
+                "Unsupported object type [type={0}, object={1}].\nSpecified type " +
+                "can not be serialized by Ignite: it is neither [Serializable], " +
+                "nor registered in IgniteConfiguration.BinaryConfiguration." +
+                "\nSee https://apacheignite-net.readme.io/docs/serialization for more details.",
type, obj));
+        }
+
+        /// <summary>
         /// Creates and instance from the type name in reader.
         /// </summary>
         private static T CreateInstance<T>(BinaryReader reader)

http://git-wip-us.apache.org/repos/asf/ignite/blob/6a2ecdbf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
index 063aa9d..585ccd3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
@@ -1259,8 +1259,8 @@ namespace Apache.Ignite.Core.Impl.Binary
                 // Are we dealing with a well-known type?
                 var handler = BinarySystemHandlers.GetWriteHandler(type);
 
-                if (handler == null)  // We did our best, object cannot be marshalled.
-                    throw new BinaryObjectException("Unsupported object type [type=" + type
+ ", object=" + obj + ']');
+                if (handler == null) // We did our best, object cannot be marshalled.
+                    throw BinaryUtils.GetUnsupportedTypeException(type, obj);
                 
                 if (handler.SupportsHandles && WriteHandle(_stream.Position, obj))
                     return;
@@ -1316,7 +1316,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                 WriteLongField(*(long*)&val0);
             }
             else
-                throw new BinaryObjectException("Unsupported object type [type=" + type.FullName
+ ", object=" + val + ']');
+                throw BinaryUtils.GetUnsupportedTypeException(type, val);
         }
 
         /// <summary>


Mime
View raw message