Skip to content

Commit a6eec27

Browse files
authored
Merge pull request #1267 from enisnazif/1254-improve-assignment-list-error
Improve the error message on the assignments page
2 parents 4c4dee7 + c09d9d3 commit a6eec27

File tree

1 file changed

+33
-13
lines changed

1 file changed

+33
-13
lines changed

nbgrader/server_extensions/assignment_list/handlers.py

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from ...apps import NbGrader
1818
from ...coursedir import CourseDirectory
19-
from ...exchange import ExchangeList, ExchangeFetchAssignment, ExchangeFetchFeedback, ExchangeSubmit
19+
from ...exchange import ExchangeList, ExchangeFetchAssignment, ExchangeFetchFeedback, ExchangeSubmit, ExchangeError
2020
from ...auth import Authenticator
2121
from ... import __version__ as nbgrader_version
2222

@@ -76,13 +76,23 @@ def list_released_assignments(self, course_id=None):
7676
config=config)
7777
assignments = lister.start()
7878

79-
except:
79+
except Exception as e:
8080
self.log.error(traceback.format_exc())
81-
retvalue = {
82-
"success": False,
83-
"value": traceback.format_exc()
84-
}
85-
81+
if isinstance(e, ExchangeError):
82+
retvalue = {
83+
"success": False,
84+
"value": """The exchange directory does not exist and could
85+
not be created. The "release" and "collect" functionality will not be available.
86+
Please see the documentation on
87+
http://nbgrader.readthedocs.io/en/stable/user_guide/managing_assignment_files.html#setting-up-the-exchange
88+
for instructions.
89+
"""
90+
}
91+
else:
92+
retvalue = {
93+
"success": False,
94+
"value": traceback.format_exc()
95+
}
8696
else:
8797
for assignment in assignments:
8898
if assignment['status'] == 'fetched':
@@ -111,13 +121,23 @@ def list_submitted_assignments(self, course_id=None):
111121
config=config)
112122
assignments = lister.start()
113123

114-
except:
124+
except Exception as e:
115125
self.log.error(traceback.format_exc())
116-
retvalue = {
117-
"success": False,
118-
"value": traceback.format_exc()
119-
}
120-
126+
if isinstance(e, ExchangeError):
127+
retvalue = {
128+
"success": False,
129+
"value": """The exchange directory does not exist and could
130+
not be created. The "release" and "collect" functionality will not be available.
131+
Please see the documentation on
132+
http://nbgrader.readthedocs.io/en/stable/user_guide/managing_assignment_files.html#setting-up-the-exchange
133+
for instructions.
134+
"""
135+
}
136+
else:
137+
retvalue = {
138+
"success": False,
139+
"value": traceback.format_exc()
140+
}
121141
else:
122142
for assignment in assignments:
123143
assignment["submissions"] = sorted(

0 commit comments

Comments
 (0)