mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Use Response parameters.
This commit is contained in:
parent
03c5bfca5f
commit
8dbd4a2a73
2 changed files with 21 additions and 0 deletions
|
|
@ -1,3 +1,7 @@
|
|||
from aiogram import types
|
||||
from .utils import json
|
||||
|
||||
|
||||
class ValidationError(Exception):
|
||||
pass
|
||||
|
||||
|
|
@ -9,3 +13,18 @@ class TelegramAPIError(Exception):
|
|||
self.method = method
|
||||
self.status = status
|
||||
self.body = body
|
||||
|
||||
def json(self):
|
||||
if not self.body:
|
||||
return None
|
||||
try:
|
||||
data = json.dumps(self.body)
|
||||
except Exception:
|
||||
data = None
|
||||
return data
|
||||
|
||||
@property
|
||||
def parameters(self):
|
||||
data = self.json()
|
||||
if data and 'parameters' in data:
|
||||
return types.ResponseParameters.deserialize(data['parameters'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue