From 7720c63bc809d2edec7a5770a0682f2f46f2bb87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 9 Feb 2018 15:59:26 +0100 Subject: [PATCH] Make error handling of file reading more robust --- src/event_handlers/source_code_event_handler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/event_handlers/source_code_event_handler.py b/src/event_handlers/source_code_event_handler.py index 6dd33d7..abb5738 100644 --- a/src/event_handlers/source_code_event_handler.py +++ b/src/event_handlers/source_code_event_handler.py @@ -59,6 +59,8 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin): def read(self, data): try: data['content'] = self.filemanager.file_contents except PermissionError: data['content'] = 'You have no permission to open that file :(' + except FileNotFoundError: data['content'] = 'This file was removed :(' + except Exception: data['content'] = 'Failed to read file :(' return data def write(self, data):