Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.onerror = function (message, source, lineno, colno, error) {
- if (typeof error === 'object' && error instanceof Error) {
- try {
- error = JSON.stringify(
- error,
- // по умолчанию поля ошибок не парсятся
- Object.getOwnPropertyNames(error),
- );
- } catch (_) {
- error = `${error.name}\n${error.message}\n${error.stack}`;
- }
- }
- fetch('/log', {
- method: 'POST',
- headers: {
- 'Content-type': 'application/json',
- 'X-CSRF-Token': getCookie('...'),
- },
- body: JSON.stringify({
- message,
- source,
- lineno,
- colno,
- error,
- }),
- });
- // eslint-disable-next-line prefer-rest-params
- next.apply(this, arguments);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement