mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
Correctly handle RPC Error for methods returning bool.
Also don't hang CallAsync on ReadRpcResult deserializing error
This commit is contained in:
parent
95d9135bd0
commit
f289b9e2e5
|
|
@ -699,18 +699,26 @@ namespace WTelegram
|
||||||
object result;
|
object result;
|
||||||
if (tcs != null)
|
if (tcs != null)
|
||||||
{
|
{
|
||||||
if (!type.IsArray)
|
try
|
||||||
result = reader.ReadTLValue(type);
|
|
||||||
else if (reader.ReadUInt32() == Layer.RpcErrorCtor)
|
|
||||||
result = reader.ReadTLObject(Layer.RpcErrorCtor);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
reader.BaseStream.Position -= 4;
|
if (!type.IsArray)
|
||||||
result = reader.ReadTLValue(type);
|
result = reader.ReadTLValue(type);
|
||||||
|
else if (reader.ReadUInt32() == Layer.RpcErrorCtor)
|
||||||
|
result = reader.ReadTLObject(Layer.RpcErrorCtor);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader.BaseStream.Position -= 4;
|
||||||
|
result = reader.ReadTLValue(type);
|
||||||
|
}
|
||||||
|
if (type.IsEnum) result = Enum.ToObject(type, result);
|
||||||
|
Log(1, "");
|
||||||
|
tcs.SetResult(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
tcs.SetException(ex);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
if (type.IsEnum) result = Enum.ToObject(type, result);
|
|
||||||
Log(1, "");
|
|
||||||
tcs.SetResult(result);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,7 @@ namespace TL
|
||||||
{
|
{
|
||||||
0x997275b5 => true,
|
0x997275b5 => true,
|
||||||
0xbc799737 => false,
|
0xbc799737 => false,
|
||||||
|
Layer.RpcErrorCtor => reader.ReadTLObject(Layer.RpcErrorCtor),
|
||||||
var value => throw new ApplicationException($"Invalid boolean value #{value:x}")
|
var value => throw new ApplicationException($"Invalid boolean value #{value:x}")
|
||||||
};
|
};
|
||||||
case TypeCode.Object:
|
case TypeCode.Object:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue