Added error handling when getting submissions #2

Merged
alex-bellon merged 1 commits from master into master 2021-03-18 17:57:03 -06:00
alex-bellon commented 2021-03-16 20:59:51 -06:00 (Migrated from github.com)
No description provided.
davekats commented 2021-03-17 08:54:44 -06:00 (Migrated from github.com)

Hi Alex, thank you for your PRs! I'm glad you found this script useful 😊
I'm curious what errors were being thrown here and where they originated? It would be nice to scope down the try/excepts a little if possible.

Hi Alex, thank you for your PRs! I'm glad you found this script useful 😊 I'm curious what errors were being thrown here and where they originated? It would be nice to scope down the try/excepts a little if possible.
alex-bellon commented 2021-03-17 22:49:15 -06:00 (Migrated from github.com)

Here is the error and traceback I was specifically getting. I imagine that this is probably just an error with my school's configuration of permissions or something, but I wanted to be able to just continue on with the script instead of having it exit out.

Traceback (most recent call last):
  File "export.py", line 620, in <module>
    course_view = getCourseView(course)
  File "export.py", line 542, in getCourseView
    course_view.assignments = findCourseAssignments(course)
  File "export.py", line 365, in findCourseAssignments
    for submission in submissions:
  File "/home/alex/.local/lib/python3.9/site-packages/canvasapi/paginated_list.py", line 48, in __iter__
    new_elements = self._grow()
  File "/home/alex/.local/lib/python3.9/site-packages/canvasapi/paginated_list.py", line 92, in _grow
    new_elements = self._get_next_page()
  File "/home/alex/.local/lib/python3.9/site-packages/canvasapi/paginated_list.py", line 56, in _get_next_page
    response = self._requester.request(
  File "/home/alex/.local/lib/python3.9/site-packages/canvasapi/requester.py", line 242, in request
    raise Unauthorized(response.json())
canvasapi.exceptions.Unauthorized: [{'message': 'user not authorized to perform that action'}]
Here is the error and traceback I was specifically getting. I imagine that this is probably just an error with my school's configuration of permissions or something, but I wanted to be able to just continue on with the script instead of having it exit out. ``` Traceback (most recent call last): File "export.py", line 620, in <module> course_view = getCourseView(course) File "export.py", line 542, in getCourseView course_view.assignments = findCourseAssignments(course) File "export.py", line 365, in findCourseAssignments for submission in submissions: File "/home/alex/.local/lib/python3.9/site-packages/canvasapi/paginated_list.py", line 48, in __iter__ new_elements = self._grow() File "/home/alex/.local/lib/python3.9/site-packages/canvasapi/paginated_list.py", line 92, in _grow new_elements = self._get_next_page() File "/home/alex/.local/lib/python3.9/site-packages/canvasapi/paginated_list.py", line 56, in _get_next_page response = self._requester.request( File "/home/alex/.local/lib/python3.9/site-packages/canvasapi/requester.py", line 242, in request raise Unauthorized(response.json()) canvasapi.exceptions.Unauthorized: [{'message': 'user not authorized to perform that action'}] ```
davekats commented 2021-03-18 17:56:32 -06:00 (Migrated from github.com)

Ah I see, thank you for the stack trace. That's interesting, the for..in loop actually throws the error when it gets to a certain submission where you don't have the right perms.

Ah I see, thank you for the stack trace. That's interesting, the for..in loop actually throws the error when it gets to a certain submission where you don't have the right perms.
davekats (Migrated from github.com) approved these changes 2021-03-18 17:56:56 -06:00
Sign in to join this conversation.
No description provided.