mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 16:31:21 +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):
|
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['filename'] = self.filemanager.filename
|
||||||
data['content'] = self.filemanager.file_contents
|
|
||||||
data['language'] = self.filemanager.language
|
data['language'] = self.filemanager.language
|
||||||
data['files'] = self.filemanager.files
|
data['files'] = self.filemanager.files
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def write(self, 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
|
data['files'] = self.filemanager.files
|
||||||
self.restart_process()
|
self.restart_process()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def select(self, data):
|
def select(self, data):
|
||||||
try: self.filemanager.select_file(data['filename'])
|
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
|
return data
|
||||||
|
|
||||||
def handle_event(self, anchor, data_json):
|
def handle_event(self, anchor, data_json):
|
||||||
|
Loading…
Reference in New Issue
Block a user