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.
This commit is contained in:
Andres G. Aragoneses 2016-10-30 16:04:32 +08:00
parent c1305ada65
commit a521466bb0

View file

@ -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;
}
}
}