Implement error handling in SourceCodeEventHandler.select_dir()

This commit is contained in:
Kristóf Tóth 2018-03-09 09:07:21 +01:00
parent 20895cb989
commit 3b241a3930

View File

@ -90,8 +90,15 @@ class SourceCodeEventHandler(TriggerlessEventHandler):
return data
def select_dir(self, data):
try: self.filemanager.workdir = data['directory']
except EnvironmentError: log.exception('Failed to select directory "{}"'.format(data['directory']))
try:
self.filemanager.workdir = data['directory']
try:
self.filemanager.select_file(self.filemanager.files[0])
data['content'] = self.filemanager.file_contents
except IndexError:
data['content'] = 'No files in this directory :('
except EnvironmentError:
log.exception('Failed to select directory "{}"'.format(data['directory']))
return data
def attach_fileinfo(self, data):