Guest User

Untitled

a guest
Aug 19th, 2019
56
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.onerror = function (message, source, lineno, colno, error) {
  2. if (typeof error === 'object' && error instanceof Error) {
  3. try {
  4. error = JSON.stringify(
  5. error,
  6. // по умолчанию поля ошибок не парсятся
  7. Object.getOwnPropertyNames(error),
  8. );
  9. } catch (_) {
  10. error = `${error.name}\n${error.message}\n${error.stack}`;
  11. }
  12. }
  13.  
  14. fetch('/log', {
  15. method: 'POST',
  16. headers: {
  17. 'Content-type': 'application/json',
  18. 'X-CSRF-Token': getCookie('...'),
  19. },
  20. body: JSON.stringify({
  21. message,
  22. source,
  23. lineno,
  24. colno,
  25. error,
  26. }),
  27. });
  28. // eslint-disable-next-line prefer-rest-params
  29. next.apply(this, arguments);
  30. };
RAW Paste Data