From c644bac4e4f221e1bf79f1f1ff7ee5f82d890a5d Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Mon, 24 Oct 2016 14:57:04 +0800 Subject: [PATCH 1/2] Fix typo in string of exception message This was meant to start with $, not including the $ char inside the string, otherwise the compiler string interpolation doesn't work. --- TLSharp.Core/Network/MtProtoSender.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index 4cf59a8..a8fd1ed 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -488,7 +488,7 @@ namespace TLSharp.Core.Network internal int DC { get; private set; } internal MigrationNeededException(int dc) - : base ("$Your phone number is registered to a different dc: {dc}. Please migrate.") + : base ($"Your phone number is registered to a different DC: {dc}. Please migrate.") { DC = dc; } From 3639ae3e8895d2bd45700b3c7275cd8fbbe43151 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Mon, 24 Oct 2016 14:58:04 +0800 Subject: [PATCH 2/2] Always include an innerException when re-throwing Hiding the previous thrown exception is a bad practice. --- TLSharp.Tests/TLSharpTests.cs | 5 +++-- TeleSharp.TL/ObjectDeserializer.cs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/TLSharp.Tests/TLSharpTests.cs b/TLSharp.Tests/TLSharpTests.cs index 97deaa6..ccd88f1 100644 --- a/TLSharp.Tests/TLSharpTests.cs +++ b/TLSharp.Tests/TLSharpTests.cs @@ -49,9 +49,10 @@ namespace TLSharp.Tests { return new TelegramClient(ApiId, ApiHash); } - catch (MissingApiConfigurationException) + catch (MissingApiConfigurationException ex) { - throw new Exception($"Please add your API settings to the `app.config` file. (More info: {MissingApiConfigurationException.InfoUrl})"); + throw new Exception($"Please add your API settings to the `app.config` file. (More info: {MissingApiConfigurationException.InfoUrl})", + ex); } } diff --git a/TeleSharp.TL/ObjectDeserializer.cs b/TeleSharp.TL/ObjectDeserializer.cs index f6e256c..3c695ab 100644 --- a/TeleSharp.TL/ObjectDeserializer.cs +++ b/TeleSharp.TL/ObjectDeserializer.cs @@ -21,7 +21,7 @@ namespace TeleSharp.TL } catch(Exception ex) { - throw new InvalidDataException("Constructor Invalid Or Context.Init Not Called !"); + throw new InvalidDataException("Constructor Invalid Or Context.Init Not Called !", ex); } if (t.IsSubclassOf(typeof(TLMethod))) {