diff --git a/src/event_handlers/source_code_event_handler.py b/src/event_handlers/source_code_event_handler.py index b92cc80..3f128cf 100644 --- a/src/event_handlers/source_code_event_handler.py +++ b/src/event_handlers/source_code_event_handler.py @@ -57,21 +57,23 @@ 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 :(' data['filename'] = self.filemanager.filename - data['content'] = self.filemanager.file_contents data['language'] = self.filemanager.language data['files'] = self.filemanager.files return data def write(self, data): - self.filemanager.file_contents = data['content'] + try: self.filemanager.file_contents = data['content'] + except Exception: log.exception('Error reading file!') data['files'] = self.filemanager.files self.restart_process() return data def select(self, data): try: self.filemanager.select_file(data['filename']) - except EnvironmentError: log.critical('Failed to select file "{}"'.format(data['filename'])) + except EnvironmentError: log.exception('Failed to select file "{}"'.format(data['filename'])) return data def handle_event(self, anchor, data_json):