Django ``window.onerror`` Report
Project description
Django window.onerror Report
Installation
pip install django-onerror
Urls.py
urlpatterns = [ url(r'^e/', include('django_onerror.urls', namespace='django_onerror')), ]
or:
urlpatterns = [ url(r'^report', err_views.err_report, name='err_report'), ]
Settings.py
INSTALLED_APPS = ( ... 'django_onerror', ... )
FrontEnd
<script> window.onerror = function(errorMessage, scriptURI, lineNo, columnNo, error) { // 构建错误对象 var errorObj = { lineNo: lineNo || null, columnNo: columnNo || null, scriptURI: scriptURI || null, errorMessage: errorMessage || null, stack: error && error.stack ? error.stack : null }; // 构建Http请求 if (XMLHttpRequest) { var xhr = new XMLHttpRequest(); xhr.open('post', '/e/report', true); xhr.setRequestHeader('Content-Type', 'application/json'); // 设置请求头 xhr.send(JSON.stringify(errorObj)); // 发送参数 } } </script>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-onerror-1.0.5.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for django_onerror-1.0.5-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28fe8ae1779404702f95dd16675db951e9ec76850b1d3be0a0606ec9e242e7eb |
|
MD5 | 8eec68c9c8953dac0a77206123a82141 |
|
BLAKE2b-256 | d47fdfad8a0fc4383cc15dcdc246ec1383d424c2a3f081e88a03d11cc7865cee |