Brasd99 commited on
Commit
399c94a
1 Parent(s): 15c5c89

Catching exceptions

Browse files
Files changed (2) hide show
  1. app.py +9 -6
  2. common/tinderwrapper.py +1 -1
app.py CHANGED
@@ -31,9 +31,12 @@ if st.button('Запуск'):
31
  status_text = st.empty()
32
  wrapper = TinderWrapper(access_token)
33
  create_folder(DUMP_FOLDER)
34
- dump = wrapper.create_dump(update_progress)
35
- save_data(dump, DUMP_FOLDER, update_progress)
36
- shutil.make_archive('output', 'zip', DUMP_FOLDER)
37
- update_progress(1.0, 'Обработка успешно завершена!')
38
- with open('output.zip', 'rb') as f:
39
- st.download_button('Скачать архив', f, file_name='output.zip')
 
 
 
 
31
  status_text = st.empty()
32
  wrapper = TinderWrapper(access_token)
33
  create_folder(DUMP_FOLDER)
34
+ try:
35
+ dump = wrapper.create_dump(update_progress)
36
+ save_data(dump, DUMP_FOLDER, update_progress)
37
+ shutil.make_archive('output', 'zip', DUMP_FOLDER)
38
+ update_progress(1.0, 'Обработка успешно завершена!')
39
+ with open('output.zip', 'rb') as f:
40
+ st.download_button('Скачать архив', f, file_name='output.zip')
41
+ except Exception as e:
42
+ st.error(e)
common/tinderwrapper.py CHANGED
@@ -45,7 +45,7 @@ class TinderWrapper():
45
  code, updates = self.get_updates(last_activity_date)
46
 
47
  if not code == 200:
48
- st.error('Неверный токен доступа')
49
 
50
  update_progress(0, 'Обрабатываю ответ Tinder...')
51
 
 
45
  code, updates = self.get_updates(last_activity_date)
46
 
47
  if not code == 200:
48
+ raise Exception('Неверный токен доступа!')
49
 
50
  update_progress(0, 'Обрабатываю ответ Tinder...')
51