Add exception handling

main
Bob Mottram 2024-02-01 10:58:15 +00:00
parent 9d7170dc93
commit 966ec3389f
1 changed files with 8 additions and 4 deletions

View File

@ -189,10 +189,14 @@ def _mark_post_as_read(actor: str, post_id: str, post_category: str) -> None:
read_file.seek(0, 0) read_file.seek(0, 0)
read_file.write(post_id + content) read_file.write(post_id + content)
except OSError as ex: except OSError as ex:
print('EX: Failed to mark post as read' + str(ex)) print('EX: Failed to mark post as read 1 ' + str(ex))
else: else
with open(read_posts_filename, 'w+', encoding='utf-8') as read_file: try::
with open(read_posts_filename, 'w+',
encoding='utf-8') as read_file:
read_file.write(post_id + '\n') read_file.write(post_id + '\n')
except OSError as ex:
print('EX: Failed to mark post as read 2 ' + str(ex))
def _has_read_post(actor: str, post_id: str, post_category: str) -> bool: def _has_read_post(actor: str, post_id: str, post_category: str) -> bool: