From c1305ada65f337c18eda5437f16f8e3af714e44c Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Sun, 30 Oct 2016 15:57:45 +0800 Subject: [PATCH] Rename MigrationNeededException to PhoneMigrationException There are different kind of MIGRATE errors that could be thrown by the Telegram API, as evidenced by this recent change: https://github.com/sochix/TLSharp/commit/b06f8a8e1174f0d2580f36039054adb25d62403e So this rename tries to make it consistent to the new exception names: * FILE_MIGRATE_x -> FileMigrationException * USER_MIGRATE_y -> UserMigrationException * PHONE_MIGRATE_z -> PhoneMigrationException --- TLSharp.Core/Network/MtProtoSender.cs | 6 +++--- TLSharp.Core/TelegramClient.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index 1f22aeb..108baf1 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -279,7 +279,7 @@ namespace TLSharp.Core.Network { var resultString = Regex.Match(errorMessage, @"\d+").Value; var dcIdx = int.Parse(resultString); - throw new MigrationNeededException(dcIdx); + throw new PhoneMigrationException(dcIdx); } else if (errorMessage.StartsWith("FILE_MIGRATE_")) { @@ -495,11 +495,11 @@ namespace TLSharp.Core.Network } } - internal class MigrationNeededException : Exception + internal class PhoneMigrationException : Exception { internal int DC { get; private set; } - internal MigrationNeededException(int dc) + internal PhoneMigrationException(int dc) : base ($"Your phone number is registered to a different DC: {dc}. Please migrate.") { DC = dc; diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 0c6f3c7..03083f4 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -124,7 +124,7 @@ namespace TLSharp.Core completed = true; } - catch (MigrationNeededException ex) + catch (PhoneMigrationException ex) { await ReconnectToDcAsync(ex.DC); }