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
b4b77ebd
Commit
b4b77ebd
authored
Jul 24, 2012
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor changes to make error handling of eternalresponse more robust
parent
c5ff830c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
common/lib/capa/inputtypes.py
+13
-2
common/lib/capa/responsetypes.py
+4
-1
No files found.
common/lib/capa/inputtypes.py
View file @
b4b77ebd
...
@@ -252,9 +252,20 @@ def textbox(element, value, status, render_template, msg=''):
...
@@ -252,9 +252,20 @@ def textbox(element, value, status, render_template, msg=''):
try
:
try
:
xhtml
=
etree
.
XML
(
html
)
xhtml
=
etree
.
XML
(
html
)
except
Exception
as
err
:
except
Exception
as
err
:
newmsg
=
'error
%
s in rendering message'
%
(
str
(
err
)
.
replace
(
'<'
,
'<'
))
log
.
debug
(
'error in textbox BAD HTML is :
%
s'
%
html
)
newmsg
+=
'<br/>Original message:
%
s'
%
msg
.
replace
(
'<'
,
'<'
)
newmsg
=
'error
%
s in rendering message'
%
(
str
(
err
)
.
replace
(
'<'
,
'<'
)
.
replace
(
'>'
,
'>'
)
.
replace
(
']]'
,
']]'
))
newmsg
+=
'<br/>Original message:
%
s'
%
msg
.
replace
(
'<'
,
'<'
)
.
replace
(
'>'
,
'>'
)
.
replace
(
']]'
,
']]'
)
context
[
'msg'
]
=
newmsg
context
[
'msg'
]
=
newmsg
log
.
debug
(
'error in textbox:
%
s'
%
newmsg
)
html
=
render_template
(
"textbox.html"
,
context
)
try
:
xhtml
=
etree
.
XML
(
html
)
except
Exception
as
err
:
log
.
debug
(
'SECONDARY error in textbox, giving up on status and msg'
)
newmsg
=
'error
%
s in rendering message'
%
(
str
(
err
)
.
replace
(
'<'
,
'<'
)
.
replace
(
'>'
,
'>'
)
.
replace
(
']]'
,
']]'
))
context
[
'msg'
]
=
newmsg
context
[
'status'
]
=
''
log
.
debug
(
'error in textbox:
%
s'
%
newmsg
)
html
=
render_template
(
"textbox.html"
,
context
)
html
=
render_template
(
"textbox.html"
,
context
)
xhtml
=
etree
.
XML
(
html
)
xhtml
=
etree
.
XML
(
html
)
return
xhtml
return
xhtml
...
...
common/lib/capa/responsetypes.py
View file @
b4b77ebd
...
@@ -795,7 +795,10 @@ main()
...
@@ -795,7 +795,10 @@ main()
try
:
try
:
rxml
=
etree
.
fromstring
(
r
.
text
)
# response is XML; prase it
rxml
=
etree
.
fromstring
(
r
.
text
)
# response is XML; prase it
except
Exception
as
err
:
except
Exception
as
err
:
msg
=
'Error
%
s - cannot parse response from external server r.text=
%
s'
%
(
err
,
r
.
text
)
etext
=
r
.
text
#etext = etext.replace('<![CDATA[','< ![ CDATA [')
etext
=
etext
.
replace
(
'<'
,
'<'
)
.
replace
(
'>'
,
'>'
)
# escape
msg
=
'Error
%
s - cannot parse response from external server r.text=
%
s'
%
(
err
,
etext
)
log
.
error
(
msg
)
log
.
error
(
msg
)
raise
Exception
(
msg
)
raise
Exception
(
msg
)
...
...
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