Skip to content

Commit f833e91

Browse files
cleaned up try/excepts in other snippets, no need for json module now
1 parent 80aff38 commit f833e91

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

classroom/snippets/classroom_snippets.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
from __future__ import print_function
16-
import json
1716
from googleapiclient import errors
1817

1918

@@ -38,7 +37,7 @@ def create_course(self):
3837
'courseState': 'PROVISIONED'
3938
}
4039
course = service.courses().create(body=course).execute()
41-
print('Course created: %s, %s' % (course.get('name'), course.get('id')))
40+
print('Course created: %s %s' % (course.get('name'), course.get('id')))
4241
# [END classroom_create_course]
4342
return course
4443

@@ -180,12 +179,10 @@ def add_student(self, course_id):
180179
% (student.get('profile').get('name').get('fullName'),
181180
course_id))
182181
except errors.HttpError as error:
183-
error = json.loads(error.content).get('error')
184-
if error.get('code') == 409:
185-
print('You are already a member of this course.')
186-
else:
187-
raise
182+
print('You are already a member of this course.')
188183
# [END classroom_add_student]
184+
return error
185+
return student
189186

190187
def create_coursework(self, course_id):
191188
""" Creates a coursework. """

0 commit comments

Comments
 (0)