mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-23 02:31:56 +00:00
Implement robust error handling in SourceCodeEventHandler
This commit is contained in:
parent
8c492df646
commit
557318af4e
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user