mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
30 lines
788 B
Python
30 lines
788 B
Python
from .utils import json
|
|
|
|
|
|
class ValidationError(Exception):
|
|
pass
|
|
|
|
|
|
class TelegramAPIError(Exception):
|
|
def __init__(self, message, method, status, body):
|
|
super(TelegramAPIError, self).__init__(
|
|
"A request to the Telegram API was unsuccessful.\n" + message)
|
|
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):
|
|
from .types import ResponseParameters
|
|
data = self.json()
|
|
if data and 'parameters' in data:
|
|
return ResponseParameters.deserialize(data['parameters'])
|