Skip to content

Commit

Permalink
Add simple message to handle canvas_page_not_found_in_course
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Oct 23, 2023
1 parent 3ac313c commit f142f4b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lms/services/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ def __init__(
class FileNotFoundInCourse(SerializableError):
"""A file wasn't found in the current course."""

def __init__(self, error_code: str, file_id):
super().__init__(error_code=error_code, details={"file_id": file_id})
def __init__(self, error_code: str, document_id):
super().__init__(error_code=error_code, details={"document_id": document_id})


class StudentNotInCourse(SerializableError):
Expand Down
15 changes: 15 additions & 0 deletions lms/static/scripts/frontend_apps/components/LaunchErrorDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,21 @@ export default function LaunchErrorDialog({
</ErrorModal>
);

case 'canvas_page_not_found_in_course':
return (
<ErrorModal
{...defaultProps}
title="Hypothesis couldn't find the page in the course"
>
<p>This might have happened because:</p>

<ul className="px-4 list-disc">
<li>The page has been deleted from Canvas</li>
<li>The course was copied from another course</li>
</ul>
</ErrorModal>
);

case 'canvas_group_set_not_found':
return (
<ErrorModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ describe('LaunchErrorDialog', () => {
hasRetry: true,
withError: true,
},
{
errorState: 'canvas_page_not_found_in_course',
expectedText: 'The page has been deleted from Canvas',
expectedTitle: "Hypothesis couldn't find the page in the course",
hasRetry: true,
withError: true,
},
{
errorState: 'd2l_file_not_found_in_course_instructor',
expectedText:
Expand Down
18 changes: 10 additions & 8 deletions lms/static/scripts/frontend_apps/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ export type LTILaunchServerErrorCode =
| 'blackboard_group_set_empty'
| 'blackboard_group_set_not_found'
| 'blackboard_student_not_in_group'
| 'd2l_file_not_found_in_course_student'
| 'd2l_file_not_found_in_course_instructor'
| 'd2l_group_set_not_found'
| 'd2l_group_set_empty'
| 'd2l_student_not_in_group'
| 'canvas_api_permission_error'
| 'canvas_file_not_found_in_course'
| 'canvas_group_set_not_found'
| 'canvas_group_set_empty'
| 'canvas_group_set_not_found'
| 'canvas_page_not_found_in_course'
| 'canvas_student_not_in_group'
| 'vitalsource_user_not_found'
| 'vitalsource_no_book_license';
| 'd2l_file_not_found_in_course_instructor'
| 'd2l_file_not_found_in_course_student'
| 'd2l_group_set_empty'
| 'd2l_group_set_not_found'
| 'd2l_student_not_in_group'
| 'vitalsource_no_book_license'
| 'vitalsource_user_not_found';

/**
* An `Error` or error-like object. This allows components in the application
Expand Down Expand Up @@ -149,6 +150,7 @@ export function isLTILaunchServerError(error: ErrorLike): error is APIError {
'd2l_student_not_in_group',
'canvas_api_permission_error',
'canvas_file_not_found_in_course',
'canvas_page_not_found_in_course',
'canvas_group_set_not_found',
'canvas_group_set_empty',
'canvas_student_not_in_group',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ export default function ErrorComponents() {
[
'canvas_api_permission_error',
'canvas_file_not_found_in_course',
'canvas_page_not_found_in_course',
'canvas_group_set_not_found',
'canvas_group_set_empty',
'canvas_student_not_in_group',
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lms/views/api/d2l/files_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_it_when_file_not_in_course(
):
course_copy_plugin.is_file_in_course.return_value = False
d2l_api_client.public_url.side_effect = FileNotFoundInCourse(
"d2l_file_not_found_in_course_instructor", file_id="FILE_ID"
"d2l_file_not_found_in_course_instructor", document_id="FILE_ID"
)
course_copy_plugin.find_matching_file_in_course.return_value = None

Expand Down

0 comments on commit f142f4b

Please sign in to comment.