mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
Added new type of DataCenterMigrateException - NetworkMigrateException
Now we catch not only PhoneMigrateException but all DataCenterMigrationExceptions and reconnect Fixes #568
This commit is contained in:
parent
133b9fdf6c
commit
0015cf494b
|
|
@ -305,6 +305,12 @@ namespace TLSharp.Core.Network
|
|||
var dcIdx = int.Parse(resultString);
|
||||
throw new UserMigrationException(dcIdx);
|
||||
}
|
||||
else if (errorMessage.StartsWith("NETWORK_MIGRATE_"))
|
||||
{
|
||||
var resultString = Regex.Match(errorMessage, @"\d+").Value;
|
||||
var dcIdx = int.Parse(resultString);
|
||||
throw new NetworkMigrationException(dcIdx);
|
||||
}
|
||||
else if (errorMessage == "PHONE_CODE_INVALID")
|
||||
{
|
||||
throw new InvalidPhoneCodeException("The numeric code used to authenticate does not match the numeric code sent by SMS/Telegram");
|
||||
|
|
@ -571,4 +577,12 @@ namespace TLSharp.Core.Network
|
|||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class NetworkMigrationException : DataCenterMigrationException
|
||||
{
|
||||
internal NetworkMigrationException(int dc)
|
||||
: base($"Network located on a different DC: {dc}.", dc)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ namespace TLSharp.Core
|
|||
|
||||
completed = true;
|
||||
}
|
||||
catch (PhoneMigrationException ex)
|
||||
catch (DataCenterMigrationException ex)
|
||||
{
|
||||
await ReconnectToDcAsync(ex.DC);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue