From 6c3a1f48bbddfd24543233b04de3839028d133ce Mon Sep 17 00:00:00 2001 From: Afshin Arani Date: Thu, 13 May 2021 01:31:05 +0430 Subject: [PATCH] TL: Make unknown constructor message more helpful --- src/TgSharp.TL/ObjectDeserializer.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/TgSharp.TL/ObjectDeserializer.cs b/src/TgSharp.TL/ObjectDeserializer.cs index 795bc269..77d785e6 100644 --- a/src/TgSharp.TL/ObjectDeserializer.cs +++ b/src/TgSharp.TL/ObjectDeserializer.cs @@ -18,7 +18,7 @@ public static object DeserializeObject(BinaryReader reader) } catch (Exception ex) { - throw new InvalidDataException("Invalid constructor, or invalid TLContext static initialization", ex); + throw new InvalidDataException($"Unknown object constructor ({Constructor}), this should not happen feel free to post an issue on our Github repository.", ex); } if (t.IsSubclassOf(typeof(TLMethod))) @@ -39,7 +39,8 @@ public static void SerializeObject(object obj, BinaryWriter writer) } public static TLVector DeserializeVector(BinaryReader reader) { - if (reader.ReadInt32() != 481674261) throw new InvalidDataException("Bad Constructor"); + int constructor = reader.ReadInt32(); + if (constructor != 481674261) throw new InvalidDataException($"Incorrect vector constructor, expected {481674261} received {constructor}"); TLVector t = new TLVector(); t.DeserializeBody(reader); return t;