Skip to content

Commit 2a851dd

Browse files
committed
Handle ExchangeError as special case
1 parent 7825e0c commit 2a851dd

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

nbgrader/server_extensions/assignment_list/handlers.py

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,23 @@ def list_released_assignments(self, course_id=None):
7676
config=config)
7777
assignments = lister.start()
7878

79-
except ExchangeError:
80-
self.log.error(traceback.format_exc())
81-
retvalue = {
82-
"success": False,
83-
"value": """The exchange directory does not exist and could
84-
not be created. The "release" and "collect" functionality will not be available.
85-
Please see the documentation on
86-
http://nbgrader.readthedocs.io/en/stable/user_guide/managing_assignment_files.html#setting-up-the-exchange
87-
for instructions.
88-
"""
89-
}
90-
79+
except Exception as e:
80+
if isinstance(e, ExchangeError):
81+
self.log.error(traceback.format_exc())
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+
}
9196
else:
9297
for assignment in assignments:
9398
if assignment['status'] == 'fetched':
@@ -116,18 +121,23 @@ def list_submitted_assignments(self, course_id=None):
116121
config=config)
117122
assignments = lister.start()
118123

119-
except ExchangeError:
120-
self.log.error(traceback.format_exc())
121-
retvalue = {
122-
"success": False,
123-
"value": """The exchange directory does not exist and could
124-
not be created. The "release" and "collect" functionality will not be available.
125-
Please see the documentation on
126-
http://nbgrader.readthedocs.io/en/stable/user_guide/managing_assignment_files.html#setting-up-the-exchange
127-
for instructions.
128-
"""
129-
}
130-
124+
except Exception as e:
125+
if isinstance(e, ExchangeError):
126+
self.log.error(traceback.format_exc())
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+
}
131141
else:
132142
for assignment in assignments:
133143
assignment["submissions"] = sorted(

0 commit comments

Comments
 (0)