Skip to content

Commit a609b2a

Browse files
cleaned up styling + fixed error handling
1 parent ecbaf02 commit a609b2a

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

classroom/snippets/snippets.py

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

1515
from __future__ import print_function
16+
from googleapiclient import errors
17+
1618

1719
class ClassroomSnippets(object):
1820
def __init__(self, service):
19-
self.service = service
21+
self.service = service
2022

2123
def add_alias_new(self):
2224
"""
23-
Creates a course with alias specification.
25+
Creates a course with alias specification.
2426
"""
2527
service = self.service
2628
# [START classroom_new_alias]
@@ -36,13 +38,13 @@ def add_alias_new(self):
3638
try:
3739
course = service.courses().create(
3840
body=course).execute()
39-
except:
41+
except errors.HttpError:
4042
print('Course Creation Failed')
4143
# [END classroom_new_alias]
4244

4345
def add_alias_existing(self):
4446
"""
45-
Adds alias to existing course.
47+
Adds alias to existing course.
4648
"""
4749
service = self.service
4850
# [START classroom_existing_alias]
@@ -55,6 +57,6 @@ def add_alias_existing(self):
5557
courseAlias = service.courses().aliases().create(
5658
courseId=courseId,
5759
body=courseAlias).execute()
58-
except:
60+
except errors.HttpError:
5961
print('Alias Creation Failed')
6062
# [END classroom_existing_alias]

0 commit comments

Comments
 (0)