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
a8afe5ed
Commit
a8afe5ed
authored
Jul 27, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change modulestore to use a logging error handler
* log errors, but don't fail
parent
9c92aef6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
common/lib/xmodule/xmodule/errorhandlers.py
+22
-2
common/lib/xmodule/xmodule/modulestore/xml.py
+2
-2
No files found.
common/lib/xmodule/xmodule/errorhandlers.py
View file @
a8afe5ed
import
logging
import
sys
import
sys
log
=
logging
.
getLogger
(
__name__
)
def
in_exception_handler
():
'''Is there an active exception?'''
return
sys
.
exc_info
()
!=
(
None
,
None
,
None
)
def
strict_error_handler
(
msg
,
exc_info
=
None
):
def
strict_error_handler
(
msg
,
exc_info
=
None
):
'''
'''
Do not let errors pass. If exc_info is not None, ignore msg, and just
Do not let errors pass. If exc_info is not None, ignore msg, and just
...
@@ -11,13 +18,26 @@ def strict_error_handler(msg, exc_info=None):
...
@@ -11,13 +18,26 @@ def strict_error_handler(msg, exc_info=None):
if
exc_info
is
not
None
:
if
exc_info
is
not
None
:
raise
exc_info
[
0
],
exc_info
[
1
],
exc_info
[
2
]
raise
exc_info
[
0
],
exc_info
[
1
],
exc_info
[
2
]
# Check if there is an exception being handled somewhere up the stack
if
in_exception_handler
():
if
sys
.
exc_info
()
!=
(
None
,
None
,
None
):
raise
raise
raise
Exception
(
msg
)
raise
Exception
(
msg
)
def
logging_error_handler
(
msg
,
exc_info
=
None
):
'''Log all errors, but otherwise let them pass, relying on the caller to
workaround.'''
if
exc_info
is
not
None
:
log
.
exception
(
msg
,
exc_info
=
exc_info
)
return
if
in_exception_handler
():
log
.
exception
(
msg
)
return
log
.
error
(
msg
)
def
ignore_errors_handler
(
msg
,
exc_info
=
None
):
def
ignore_errors_handler
(
msg
,
exc_info
=
None
):
'''Ignore all errors, relying on the caller to workaround.
'''Ignore all errors, relying on the caller to workaround.
Meant for use in the LMS, where an error in one part of the course
Meant for use in the LMS, where an error in one part of the course
...
...
common/lib/xmodule/xmodule/modulestore/xml.py
View file @
a8afe5ed
...
@@ -3,7 +3,7 @@ from fs.osfs import OSFS
...
@@ -3,7 +3,7 @@ from fs.osfs import OSFS
from
importlib
import
import_module
from
importlib
import
import_module
from
lxml
import
etree
from
lxml
import
etree
from
path
import
path
from
path
import
path
from
xmodule.errorhandlers
import
strict
_error_handler
from
xmodule.errorhandlers
import
logging
_error_handler
from
xmodule.x_module
import
XModuleDescriptor
,
XMLParsingSystem
from
xmodule.x_module
import
XModuleDescriptor
,
XMLParsingSystem
from
xmodule.mako_module
import
MakoDescriptorSystem
from
xmodule.mako_module
import
MakoDescriptorSystem
from
cStringIO
import
StringIO
from
cStringIO
import
StringIO
...
@@ -100,7 +100,7 @@ class XMLModuleStore(ModuleStore):
...
@@ -100,7 +100,7 @@ class XMLModuleStore(ModuleStore):
"""
"""
def
__init__
(
self
,
data_dir
,
default_class
=
None
,
eager
=
False
,
def
__init__
(
self
,
data_dir
,
default_class
=
None
,
eager
=
False
,
course_dirs
=
None
,
course_dirs
=
None
,
error_handler
=
strict
_error_handler
):
error_handler
=
logging
_error_handler
):
"""
"""
Initialize an XMLModuleStore from data_dir
Initialize an XMLModuleStore from data_dir
...
...
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