From a521466bb02c97eac845240e59511248aff8886e Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Sun, 30 Oct 2016 16:04:32 +0800 Subject: [PATCH] Create common abstract DataCenterMigrationException We can abstract the DC property to a common abstract class so have a bit of less code and we join these 3 classes together semantically. --- TLSharp.Core/Network/MtProtoSender.cs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index 108baf1..6966028 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -495,36 +495,37 @@ namespace TLSharp.Core.Network } } - internal class PhoneMigrationException : Exception + internal abstract class DataCenterMigrationException : Exception { internal int DC { get; private set; } + protected DataCenterMigrationException(string msg, int dc) : base (msg) + { + DC = dc; + } + } + + internal class PhoneMigrationException : DataCenterMigrationException + { internal PhoneMigrationException(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 = dc; } } - internal class FileMigrationException : Exception + internal class FileMigrationException : DataCenterMigrationException { - internal int DC { get; private set; } - internal FileMigrationException(int dc) - : base ($"File is located on a different DC: {dc}. Please migrate.") + : base ($"File is located on a different DC: {dc}. Please migrate.", dc) { - DC = dc; } } - internal class UserMigrationException : Exception + internal class UserMigrationException : DataCenterMigrationException { - internal int DC { get; private set; } - internal UserMigrationException(int dc) - : base($"User is located on a different DC: {dc}. Please migrate.") + : base($"User is located on a different DC: {dc}. Please migrate.", dc) { - DC = dc; } } } \ No newline at end of file