Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sebastien Robin
erp5
Commits
aba3d435
Commit
aba3d435
authored
May 02, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Increase verbosity of the error rendering
This is nearly a copy/paste of renderJS error rendering.
parent
f230974a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
258 additions
and
26 deletions
+258
-26
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.js
...mplateItem/web_page_module/rjs_gadget_erp5_launcher_js.js
+109
-24
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.xml
...plateItem/web_page_module/rjs_gadget_erp5_launcher_js.xml
+2
-2
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_zuite/testErrorPageFirstLoad.xml
...portal_tests/renderjs_ui_zuite/testErrorPageFirstLoad.xml
+58
-0
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_zuite/testErrorPageFirstLoad.zpt
...portal_tests/renderjs_ui_zuite/testErrorPageFirstLoad.zpt
+89
-0
No files found.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.js
View file @
aba3d435
...
@@ -100,30 +100,70 @@
...
@@ -100,30 +100,70 @@
return
route
(
gadget
,
'
jio_gadget
'
,
method
,
param_list
);
return
route
(
gadget
,
'
jio_gadget
'
,
method
,
param_list
);
}
}
function
displayErrorContent
(
gadget
,
error
)
{
function
displayErrorContent
(
gadget
,
original_error
)
{
var
error_list
=
[
original_error
],
i
,
error
,
error_text
=
""
;
// Do not break the application in case of errors.
// Do not break the application in case of errors.
// Display it to the user for now,
// Display it to the user for now,
// and allow user to go back to the frontpage
// and allow user to go back to the frontpage
var
error_text
=
""
;
if
(
error
instanceof
ProgressEvent
)
{
error
=
error
.
target
.
error
;
}
if
((
error
!==
undefined
)
&&
(
error
.
target
instanceof
XMLHttpRequest
))
{
// Add error handling stack
error_text
=
error
.
target
.
toString
()
+
"
"
+
error_list
.
push
(
new
Error
(
'
stopping ERP5JS
'
));
error
.
target
.
status
+
"
"
+
error
.
target
.
statusText
+
"
\n
"
+
for
(
i
=
0
;
i
<
error_list
.
length
;
i
+=
1
)
{
error
.
target
.
responseURL
+
"
\n\n
"
+
error
=
error_list
[
i
];
error
.
target
.
getAllResponseHeaders
();
if
(
error
instanceof
Event
)
{
}
else
if
(
error
instanceof
Error
)
{
error
=
{
error_text
=
error
.
toString
();
string
:
error
.
toString
(),
}
else
{
message
:
error
.
message
,
error_text
=
JSON
.
stringify
(
error
);
type
:
error
.
type
,
target
:
error
.
target
};
if
(
error
.
target
!==
undefined
)
{
error_list
.
splice
(
i
+
1
,
0
,
error
.
target
);
}
}
if
(
error
instanceof
XMLHttpRequest
)
{
error
=
{
message
:
error
.
toString
(),
readyState
:
error
.
readyState
,
status
:
error
.
status
,
statusText
:
error
.
statusText
,
response
:
error
.
response
,
responseUrl
:
error
.
responseUrl
,
response_headers
:
error
.
getAllResponseHeaders
()
};
}
if
(
error
.
constructor
===
Array
||
error
.
constructor
===
String
||
error
.
constructor
===
Object
)
{
try
{
error
=
JSON
.
stringify
(
error
);
}
catch
(
ignore
)
{
}
}
error_text
+=
error
.
message
||
error
;
error_text
+=
'
\n
'
;
if
(
error
.
fileName
!==
undefined
)
{
error_text
+=
'
File:
'
+
error
.
fileName
+
'
:
'
+
error
.
lineNumber
+
'
\n
'
;
}
if
(
error
.
stack
!==
undefined
)
{
error_text
+=
'
Stack:
'
+
error
.
stack
+
'
\n
'
;
}
error_text
+=
'
---
\n
'
;
}
}
console
.
error
(
error
);
console
.
error
(
original_
error
);
if
(
error
instanceof
Error
)
{
if
(
original_
error
instanceof
Error
)
{
console
.
error
(
error
.
stack
);
console
.
error
(
original_
error
.
stack
);
}
}
if
(
gadget
.
props
===
undefined
)
{
if
(
gadget
.
props
===
undefined
)
{
// Gadget has not yet been correctly initialized
// Gadget has not yet been correctly initialized
...
@@ -600,14 +640,59 @@
...
@@ -600,14 +640,59 @@
return
;
return
;
})
})
.
push
(
function
()
{
.
push
(
function
()
{
// XXX Improve error rendering
var
element
=
gadget
.
props
.
content_element
,
gadget
.
props
.
content_element
.
innerHTML
=
container
=
document
.
createElement
(
"
section
"
),
"
<br/><br/><br/><pre></pre>
"
;
paragraph
,
gadget
.
props
.
content_element
.
querySelector
(
'
pre
'
).
textContent
=
link
;
"
Error:
"
+
gadget
.
state
.
error_text
;
paragraph
=
document
.
createElement
(
"
p
"
);
paragraph
.
textContent
=
'
Please report this unhandled error to the support team,
'
+
'
and go back to the
'
;
link
=
document
.
createElement
(
"
a
"
);
link
.
href
=
'
#
'
;
link
.
textContent
=
'
homepage
'
;
paragraph
.
appendChild
(
link
);
container
.
appendChild
(
paragraph
);
container
.
appendChild
(
document
.
createElement
(
"
br
"
));
paragraph
=
document
.
createElement
(
"
p
"
);
paragraph
.
textContent
=
'
Location:
'
;
link
=
document
.
createElement
(
"
a
"
);
link
.
href
=
link
.
textContent
=
window
.
location
.
toString
();
paragraph
.
appendChild
(
link
);
container
.
appendChild
(
paragraph
);
paragraph
=
document
.
createElement
(
"
p
"
);
paragraph
.
textContent
=
'
User-agent:
'
+
navigator
.
userAgent
;
container
.
appendChild
(
paragraph
);
paragraph
=
document
.
createElement
(
"
p
"
);
paragraph
.
textContent
=
'
Date:
'
+
new
Date
(
Date
.
now
()).
toISOString
();
container
.
appendChild
(
paragraph
);
paragraph
=
document
.
createElement
(
"
p
"
);
paragraph
.
textContent
=
'
Online:
'
+
navigator
.
onLine
;
container
.
appendChild
(
paragraph
);
container
.
appendChild
(
document
.
createElement
(
"
br
"
));
link
=
document
.
createElement
(
"
code
"
);
link
.
textContent
=
gadget
.
state
.
error_text
;
paragraph
=
document
.
createElement
(
"
pre
"
);
paragraph
.
appendChild
(
link
);
container
.
appendChild
(
paragraph
);
// Remove the content
while
(
element
.
firstChild
)
{
element
.
removeChild
(
element
.
firstChild
);
}
element
.
appendChild
(
container
);
// reset gadget state
// reset gadget state
gadget
.
state
=
JSON
.
parse
(
default_state_json_string
);
gadget
.
state
=
JSON
.
parse
(
default_state_json_string
);
// XXX Notify error
});
});
}
}
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_launcher_js.xml
View file @
aba3d435
...
@@ -228,7 +228,7 @@
...
@@ -228,7 +228,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
97
1.61005.64164.54442
</string>
</value>
<value>
<string>
97
5.29285.197.41386
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -246,7 +246,7 @@
...
@@ -246,7 +246,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
15
43420133.66
</float>
<float>
15
56813529.18
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_zuite/testErrorPageFirstLoad.xml
0 → 100644
View file @
aba3d435
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ZopePageTemplate"
module=
"Products.PageTemplates.ZopePageTemplate"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
content_type
</string>
</key>
<value>
<string>
text/html
</string>
</value>
</item>
<item>
<key>
<string>
expand
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
testErrorPageFirstLoad
</string>
</value>
</item>
<item>
<key>
<string>
output_encoding
</string>
</key>
<value>
<string>
utf-8
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<unicode></unicode>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_zuite/testErrorPageFirstLoad.zpt
0 → 100644
View file @
aba3d435
<html
xmlns:tal=
"http://xml.zope.org/namespaces/tal"
xmlns:metal=
"http://xml.zope.org/namespaces/metal"
>
<head>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
>
<title>
Test RenderJS UI
</title>
</head>
<body>
<table
cellpadding=
"1"
cellspacing=
"1"
border=
"1"
>
<thead>
<tr><td
rowspan=
"1"
colspan=
"3"
>
Test RenderJS UI
</td></tr>
</thead><tbody>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplate/macros/init"
/>
<!-- Initialize -->
<tr>
<td>
open
</td>
<td>
${base_url}/web_site_module/renderjs_runner/#/?page=foobar
</td>
<td></td>
</tr>
<tr>
<td
colspan=
"3"
><b>
Wait for the error to be displayed
</b></td>
</tr>
<tr>
<td>
waitForElementPresent
</td>
<td>
//div[@class="ui-icon-spinner ui-btn-icon-notext first-loader"]
</td>
<td></td>
</tr>
<tr>
<td>
assertElementPresent
</td>
<td>
//div[@class="ui-icon-spinner ui-btn-icon-notext first-loader"]
</td>
<td></td>
</tr>
<tr>
<td>
waitForElementNotPresent
</td>
<td>
//div[@class="ui-icon-spinner ui-btn-icon-notext first-loader"]
</td>
<td></td>
</tr>
<tr>
<td>
assertElementNotPresent
</td>
<td>
//div[@class="ui-icon-spinner ui-btn-icon-notext first-loader"]
</td>
<td></td>
</tr>
<tr>
<td
colspan=
"3"
><p></p></td>
</tr>
<tr>
<td>
assertTextPresent
</td>
<td>
"status":404
</td>
<td></td>
</tr>
<tr>
<td>
assertTextPresent
</td>
<td>
Please report this unhandled error to the support team, and go back to the homepage
</td>
<td></td>
</tr>
<tr>
<td>
assertTextPresent
</td>
<td>
#/?page=foobar
</td>
<td></td>
</tr>
<tr>
<td
colspan=
"3"
><b>
Go back to the homepage
</b></td>
</tr>
<tr>
<td>
click
</td>
<td>
//div[@role='main']//a[text()='homepage' and @href='#']
</td>
<td></td>
</tr>
<tr>
<td
colspan=
"3"
><p></p></td>
</tr>
<tr>
<td>
waitForElementPresent
</td>
<td>
//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_worklist.html']
</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
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