2019-10-17 19:03:09 +02:00
|
|
|
class NoArgError(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class StationNotFoundError(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2020-09-14 20:41:54 +02:00
|
|
|
class WeatherStationNotFoundError(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2019-10-17 19:03:09 +02:00
|
|
|
class ServerCommunicationError(Exception):
|
|
|
|
pass
|
2019-10-17 20:19:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
class MultipleStationsFoundError(Exception):
|
|
|
|
message_text = ''
|
|
|
|
queried_station = ''
|
|
|
|
station_list = []
|
|
|
|
|
|
|
|
def __init__(self, message_text, queried_station, station_list):
|
|
|
|
self.message_text = message_text
|
|
|
|
self.queried_station = queried_station
|
|
|
|
self.station_list = station_list
|
2020-09-14 20:41:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
def error_callback(update, context):
|
|
|
|
try:
|
|
|
|
raise context.error
|
|
|
|
except NoArgError:
|
|
|
|
update.message.reply_text('No argument specified!')
|
|
|
|
return
|
|
|
|
except StationNotFoundError:
|
|
|
|
update.message.reply_text('No station matching this name found!')
|
|
|
|
return
|
|
|
|
except ServerCommunicationError:
|
|
|
|
update.message.reply_text('Error with server communication')
|
|
|
|
return
|
|
|
|
except WeatherStationNotFoundError:
|
|
|
|
update.message.reply_text('No weather station matching this name found!')
|