mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
Exceptions moved to separate folders (#899)
Exceptions from MtProtoSender.cs to TLSharp.Core/Network/Exceptions Exceptions from TelegramClient.cs to TLSharp.Core/Exceptions
This commit is contained in:
parent
0a91487ea7
commit
8729b7d85b
9
TLSharp.Core/Exceptions/CloudPasswordNeededException.cs
Normal file
9
TLSharp.Core/Exceptions/CloudPasswordNeededException.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace TLSharp.Core.Exceptions
|
||||||
|
{
|
||||||
|
public class CloudPasswordNeededException : Exception
|
||||||
|
{
|
||||||
|
internal CloudPasswordNeededException(string msg) : base(msg) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
9
TLSharp.Core/Exceptions/InvalidPhoneCodeException.cs
Normal file
9
TLSharp.Core/Exceptions/InvalidPhoneCodeException.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace TLSharp.Core.Exceptions
|
||||||
|
{
|
||||||
|
public class InvalidPhoneCodeException : Exception
|
||||||
|
{
|
||||||
|
internal InvalidPhoneCodeException(string msg) : base(msg) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
14
TLSharp.Core/Exceptions/MissingApiConfigurationException.cs
Normal file
14
TLSharp.Core/Exceptions/MissingApiConfigurationException.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace TLSharp.Core.Exceptions
|
||||||
|
{
|
||||||
|
public class MissingApiConfigurationException : Exception
|
||||||
|
{
|
||||||
|
public const string InfoUrl = "https://github.com/sochix/TLSharp#quick-configuration";
|
||||||
|
|
||||||
|
internal MissingApiConfigurationException(string invalidParamName) :
|
||||||
|
base($"Your {invalidParamName} setting is missing. Adjust the configuration first, see {InfoUrl}")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace TLSharp.Core.Network.Exceptions
|
||||||
|
{
|
||||||
|
internal abstract class DataCenterMigrationException : Exception
|
||||||
|
{
|
||||||
|
internal int DC { get; private set; }
|
||||||
|
|
||||||
|
private const string REPORT_MESSAGE =
|
||||||
|
" See: https://github.com/sochix/TLSharp#i-get-a-xxxmigrationexception-or-a-migrate_x-error";
|
||||||
|
|
||||||
|
protected DataCenterMigrationException(string msg, int dc) : base (msg + REPORT_MESSAGE)
|
||||||
|
{
|
||||||
|
DC = dc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
TLSharp.Core/Network/Exceptions/FileMigrationException.cs
Normal file
10
TLSharp.Core/Network/Exceptions/FileMigrationException.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace TLSharp.Core.Network.Exceptions
|
||||||
|
{
|
||||||
|
internal class FileMigrationException : DataCenterMigrationException
|
||||||
|
{
|
||||||
|
internal FileMigrationException(int dc)
|
||||||
|
: base ($"File located on a different DC: {dc}.", dc)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
TLSharp.Core/Network/Exceptions/FloodException.cs
Normal file
16
TLSharp.Core/Network/Exceptions/FloodException.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace TLSharp.Core.Network.Exceptions
|
||||||
|
{
|
||||||
|
public class FloodException : Exception
|
||||||
|
{
|
||||||
|
public TimeSpan TimeToWait { get; private set; }
|
||||||
|
|
||||||
|
internal FloodException(TimeSpan timeToWait)
|
||||||
|
: base($"Flood prevention. Telegram now requires your program to do requests again only after {timeToWait.TotalSeconds} seconds have passed ({nameof(TimeToWait)} property)." +
|
||||||
|
" If you think the culprit of this problem may lie in TLSharp's implementation, open a Github issue please.")
|
||||||
|
{
|
||||||
|
TimeToWait = timeToWait;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
TLSharp.Core/Network/Exceptions/NetworkMigrationException.cs
Normal file
10
TLSharp.Core/Network/Exceptions/NetworkMigrationException.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace TLSharp.Core.Network.Exceptions
|
||||||
|
{
|
||||||
|
internal class NetworkMigrationException : DataCenterMigrationException
|
||||||
|
{
|
||||||
|
internal NetworkMigrationException(int dc)
|
||||||
|
: base($"Network located on a different DC: {dc}.", dc)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
TLSharp.Core/Network/Exceptions/PhoneMigrationException.cs
Normal file
10
TLSharp.Core/Network/Exceptions/PhoneMigrationException.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace TLSharp.Core.Network.Exceptions
|
||||||
|
{
|
||||||
|
internal class PhoneMigrationException : DataCenterMigrationException
|
||||||
|
{
|
||||||
|
internal PhoneMigrationException(int dc)
|
||||||
|
: base ($"Phone number registered to a different DC: {dc}.", dc)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
TLSharp.Core/Network/Exceptions/UserMigrationException.cs
Normal file
10
TLSharp.Core/Network/Exceptions/UserMigrationException.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace TLSharp.Core.Network.Exceptions
|
||||||
|
{
|
||||||
|
internal class UserMigrationException : DataCenterMigrationException
|
||||||
|
{
|
||||||
|
internal UserMigrationException(int dc)
|
||||||
|
: base($"User located on a different DC: {dc}.", dc)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,8 +7,10 @@ using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Ionic.Zlib;
|
using Ionic.Zlib;
|
||||||
|
using TLSharp.Core.Exceptions;
|
||||||
using TLSharp.Core.MTProto;
|
using TLSharp.Core.MTProto;
|
||||||
using TLSharp.Core.MTProto.Crypto;
|
using TLSharp.Core.MTProto.Crypto;
|
||||||
|
using TLSharp.Core.Network.Exceptions;
|
||||||
using TLSharp.Core.Requests;
|
using TLSharp.Core.Requests;
|
||||||
using TLSharp.Core.Utils;
|
using TLSharp.Core.Utils;
|
||||||
|
|
||||||
|
|
@ -523,61 +525,4 @@ namespace TLSharp.Core.Network
|
||||||
return new MemoryStream(new byte[len], 0, len, true, true);
|
return new MemoryStream(new byte[len], 0, len, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FloodException : Exception
|
|
||||||
{
|
|
||||||
public TimeSpan TimeToWait { get; private set; }
|
|
||||||
|
|
||||||
internal FloodException(TimeSpan timeToWait)
|
|
||||||
: base($"Flood prevention. Telegram now requires your program to do requests again only after {timeToWait.TotalSeconds} seconds have passed ({nameof(TimeToWait)} property)." +
|
|
||||||
" If you think the culprit of this problem may lie in TLSharp's implementation, open a Github issue please.")
|
|
||||||
{
|
|
||||||
TimeToWait = timeToWait;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal abstract class DataCenterMigrationException : Exception
|
|
||||||
{
|
|
||||||
internal int DC { get; private set; }
|
|
||||||
|
|
||||||
private const string REPORT_MESSAGE =
|
|
||||||
" See: https://github.com/sochix/TLSharp#i-get-a-xxxmigrationexception-or-a-migrate_x-error";
|
|
||||||
|
|
||||||
protected DataCenterMigrationException(string msg, int dc) : base (msg + REPORT_MESSAGE)
|
|
||||||
{
|
|
||||||
DC = dc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class PhoneMigrationException : DataCenterMigrationException
|
|
||||||
{
|
|
||||||
internal PhoneMigrationException(int dc)
|
|
||||||
: base ($"Phone number registered to a different DC: {dc}.", dc)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class FileMigrationException : DataCenterMigrationException
|
|
||||||
{
|
|
||||||
internal FileMigrationException(int dc)
|
|
||||||
: base ($"File located on a different DC: {dc}.", dc)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class UserMigrationException : DataCenterMigrationException
|
|
||||||
{
|
|
||||||
internal UserMigrationException(int dc)
|
|
||||||
: base($"User located on a different DC: {dc}.", dc)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class NetworkMigrationException : DataCenterMigrationException
|
|
||||||
{
|
|
||||||
internal NetworkMigrationException(int dc)
|
|
||||||
: base($"Network located on a different DC: {dc}.", dc)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,9 @@
|
||||||
<Compile Include="Auth\Step1_PQRequest.cs" />
|
<Compile Include="Auth\Step1_PQRequest.cs" />
|
||||||
<Compile Include="Auth\Step2_DHExchange.cs" />
|
<Compile Include="Auth\Step2_DHExchange.cs" />
|
||||||
<Compile Include="Auth\Step3_CompleteDHExchange.cs" />
|
<Compile Include="Auth\Step3_CompleteDHExchange.cs" />
|
||||||
|
<Compile Include="Exceptions\CloudPasswordNeededException.cs" />
|
||||||
|
<Compile Include="Exceptions\InvalidPhoneCodeException.cs" />
|
||||||
|
<Compile Include="Exceptions\MissingApiConfigurationException.cs" />
|
||||||
<Compile Include="MTProto\Crypto\AES.cs" />
|
<Compile Include="MTProto\Crypto\AES.cs" />
|
||||||
<Compile Include="MTProto\Crypto\AuthKey.cs" />
|
<Compile Include="MTProto\Crypto\AuthKey.cs" />
|
||||||
<Compile Include="MTProto\Crypto\BigInteger.cs" />
|
<Compile Include="MTProto\Crypto\BigInteger.cs" />
|
||||||
|
|
@ -57,10 +60,16 @@
|
||||||
<Compile Include="MTProto\Crypto\RSA.cs" />
|
<Compile Include="MTProto\Crypto\RSA.cs" />
|
||||||
<Compile Include="MTProto\Crypto\Salt.cs" />
|
<Compile Include="MTProto\Crypto\Salt.cs" />
|
||||||
<Compile Include="MTProto\Serializers.cs" />
|
<Compile Include="MTProto\Serializers.cs" />
|
||||||
|
<Compile Include="Network\Exceptions\DataCenterMigrationException.cs" />
|
||||||
|
<Compile Include="Network\Exceptions\FileMigrationException.cs" />
|
||||||
|
<Compile Include="Network\Exceptions\FloodException.cs" />
|
||||||
<Compile Include="Network\MtProtoPlainSender.cs" />
|
<Compile Include="Network\MtProtoPlainSender.cs" />
|
||||||
<Compile Include="Network\MtProtoSender.cs" />
|
<Compile Include="Network\MtProtoSender.cs" />
|
||||||
|
<Compile Include="Network\Exceptions\NetworkMigrationException.cs" />
|
||||||
|
<Compile Include="Network\Exceptions\PhoneMigrationException.cs" />
|
||||||
<Compile Include="Network\TcpMessage.cs" />
|
<Compile Include="Network\TcpMessage.cs" />
|
||||||
<Compile Include="Network\TcpTransport.cs" />
|
<Compile Include="Network\TcpTransport.cs" />
|
||||||
|
<Compile Include="Network\Exceptions\UserMigrationException.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Requests\AckRequest.cs" />
|
<Compile Include="Requests\AckRequest.cs" />
|
||||||
<Compile Include="Requests\PingRequest.cs" />
|
<Compile Include="Requests\PingRequest.cs" />
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,10 @@ using TeleSharp.TL.Help;
|
||||||
using TeleSharp.TL.Messages;
|
using TeleSharp.TL.Messages;
|
||||||
using TeleSharp.TL.Upload;
|
using TeleSharp.TL.Upload;
|
||||||
using TLSharp.Core.Auth;
|
using TLSharp.Core.Auth;
|
||||||
|
using TLSharp.Core.Exceptions;
|
||||||
using TLSharp.Core.MTProto.Crypto;
|
using TLSharp.Core.MTProto.Crypto;
|
||||||
using TLSharp.Core.Network;
|
using TLSharp.Core.Network;
|
||||||
|
using TLSharp.Core.Network.Exceptions;
|
||||||
using TLSharp.Core.Utils;
|
using TLSharp.Core.Utils;
|
||||||
using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization;
|
using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization;
|
||||||
|
|
||||||
|
|
@ -446,23 +448,4 @@ namespace TLSharp.Core
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MissingApiConfigurationException : Exception
|
|
||||||
{
|
|
||||||
public const string InfoUrl = "https://github.com/sochix/TLSharp#quick-configuration";
|
|
||||||
|
|
||||||
internal MissingApiConfigurationException(string invalidParamName) :
|
|
||||||
base($"Your {invalidParamName} setting is missing. Adjust the configuration first, see {InfoUrl}")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InvalidPhoneCodeException : Exception
|
|
||||||
{
|
|
||||||
internal InvalidPhoneCodeException(string msg) : base(msg) { }
|
|
||||||
}
|
|
||||||
public class CloudPasswordNeededException : Exception
|
|
||||||
{
|
|
||||||
internal CloudPasswordNeededException(string msg) : base(msg) { }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,9 @@ using System.Threading.Tasks;
|
||||||
using TeleSharp.TL;
|
using TeleSharp.TL;
|
||||||
using TeleSharp.TL.Messages;
|
using TeleSharp.TL.Messages;
|
||||||
using TLSharp.Core;
|
using TLSharp.Core;
|
||||||
|
using TLSharp.Core.Exceptions;
|
||||||
using TLSharp.Core.Network;
|
using TLSharp.Core.Network;
|
||||||
|
using TLSharp.Core.Network.Exceptions;
|
||||||
using TLSharp.Core.Requests;
|
using TLSharp.Core.Requests;
|
||||||
using TLSharp.Core.Utils;
|
using TLSharp.Core.Utils;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue