Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
08a0c639
Commit
08a0c639
authored
Sep 04, 2014
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5070 from edx/reruns/error-handling
Course Rerun: include stack trace in errors and Log errors.
parents
97527266
bdd91dae
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
10 deletions
+31
-10
cms/djangoapps/contentstore/tasks.py
+5
-2
cms/djangoapps/contentstore/tests/test_contentstore.py
+12
-0
common/djangoapps/course_action_state/managers.py
+4
-3
common/djangoapps/course_action_state/tests/test_rerun_manager.py
+10
-5
No files found.
cms/djangoapps/contentstore/tasks.py
View file @
08a0c639
...
@@ -5,6 +5,7 @@ This file contains celery tasks for contentstore views
...
@@ -5,6 +5,7 @@ This file contains celery tasks for contentstore views
from
celery.task
import
task
from
celery.task
import
task
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
import
json
import
json
import
logging
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.course_module
import
CourseFields
from
xmodule.course_module
import
CourseFields
...
@@ -40,13 +41,15 @@ def rerun_course(source_course_key_string, destination_course_key_string, user_i
...
@@ -40,13 +41,15 @@ def rerun_course(source_course_key_string, destination_course_key_string, user_i
except
DuplicateCourseError
as
exc
:
except
DuplicateCourseError
as
exc
:
# do NOT delete the original course, only update the status
# do NOT delete the original course, only update the status
CourseRerunState
.
objects
.
failed
(
course_key
=
destination_course_key
,
exception
=
exc
)
CourseRerunState
.
objects
.
failed
(
course_key
=
destination_course_key
)
logging
.
exception
(
u'Course Rerun Error'
)
return
"duplicate course"
return
"duplicate course"
# catch all exceptions so we can update the state and properly cleanup the course.
# catch all exceptions so we can update the state and properly cleanup the course.
except
Exception
as
exc
:
# pylint: disable=broad-except
except
Exception
as
exc
:
# pylint: disable=broad-except
# update state: Failed
# update state: Failed
CourseRerunState
.
objects
.
failed
(
course_key
=
destination_course_key
,
exception
=
exc
)
CourseRerunState
.
objects
.
failed
(
course_key
=
destination_course_key
)
logging
.
exception
(
u'Course Rerun Error'
)
try
:
try
:
# cleanup any remnants of the course
# cleanup any remnants of the course
...
...
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
08a0c639
...
@@ -1699,6 +1699,18 @@ class RerunCourseTest(ContentStoreTestCase):
...
@@ -1699,6 +1699,18 @@ class RerunCourseTest(ContentStoreTestCase):
self
.
user
.
save
()
self
.
user
.
save
()
self
.
post_rerun_request
(
source_course
.
id
,
response_code
=
403
,
expect_error
=
True
)
self
.
post_rerun_request
(
source_course
.
id
,
response_code
=
403
,
expect_error
=
True
)
def
test_rerun_error
(
self
):
error_message
=
"Mock Error Message"
with
mock
.
patch
(
'xmodule.modulestore.mixed.MixedModuleStore.clone_course'
,
mock
.
Mock
(
side_effect
=
Exception
(
error_message
))
):
source_course
=
CourseFactory
.
create
()
destination_course_key
=
self
.
post_rerun_request
(
source_course
.
id
)
rerun_state
=
CourseRerunState
.
objects
.
find_first
(
course_key
=
destination_course_key
)
self
.
assertEquals
(
rerun_state
.
state
,
CourseRerunUIStateManager
.
State
.
FAILED
)
self
.
assertIn
(
error_message
,
rerun_state
.
message
)
class
EntryPageTestCase
(
TestCase
):
class
EntryPageTestCase
(
TestCase
):
"""
"""
...
...
common/djangoapps/course_action_state/managers.py
View file @
08a0c639
"""
"""
Model Managers for Course Actions
Model Managers for Course Actions
"""
"""
import
traceback
from
django.db
import
models
,
transaction
from
django.db
import
models
,
transaction
...
@@ -135,14 +136,14 @@ class CourseRerunUIStateManager(CourseActionUIStateManager):
...
@@ -135,14 +136,14 @@ class CourseRerunUIStateManager(CourseActionUIStateManager):
new_state
=
self
.
State
.
SUCCEEDED
,
new_state
=
self
.
State
.
SUCCEEDED
,
)
)
def
failed
(
self
,
course_key
,
exception
):
def
failed
(
self
,
course_key
):
"""
"""
To be called w
hen an existing rerun for the given course has failed with the given exception
.
To be called w
ithin an exception handler when an existing rerun for the given course has failed
.
"""
"""
self
.
update_state
(
self
.
update_state
(
course_key
=
course_key
,
course_key
=
course_key
,
new_state
=
self
.
State
.
FAILED
,
new_state
=
self
.
State
.
FAILED
,
message
=
exception
.
message
,
message
=
traceback
.
format_exc
()
,
)
)
...
...
common/djangoapps/course_action_state/tests/test_rerun_manager.py
View file @
08a0c639
...
@@ -91,12 +91,17 @@ class TestCourseRerunStateManager(TestCase):
...
@@ -91,12 +91,17 @@ class TestCourseRerunStateManager(TestCase):
# set state to fail
# set state to fail
exception
=
Exception
(
"failure in rerunning"
)
exception
=
Exception
(
"failure in rerunning"
)
CourseRerunState
.
objects
.
failed
(
course_key
=
self
.
course_key
,
exception
=
exception
)
try
:
self
.
expected_rerun_state
.
update
({
raise
exception
'state'
:
CourseRerunUIStateManager
.
State
.
FAILED
,
except
:
'message'
:
exception
.
message
,
CourseRerunState
.
objects
.
failed
(
course_key
=
self
.
course_key
)
})
self
.
expected_rerun_state
.
update
(
{
'state'
:
CourseRerunUIStateManager
.
State
.
FAILED
}
)
self
.
expected_rerun_state
.
pop
(
'message'
)
rerun
=
self
.
verify_rerun_state
()
rerun
=
self
.
verify_rerun_state
()
self
.
assertIn
(
exception
.
message
,
rerun
.
message
)
# dismiss ui and verify
# dismiss ui and verify
self
.
dismiss_ui_and_verify
(
rerun
)
self
.
dismiss_ui_and_verify
(
rerun
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment