| 1 | import { muestraError } from "./muestraError.js" |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | { |
| 8 | const originalJson = Response.prototype.json |
| 9 | |
| 10 | Response.prototype.json = function () { |
| 11 | |
| 12 | return originalJson.apply(this, arguments) |
| 13 | .catch(( error) => { |
| 14 | |
| 15 | throw new Error(error) |
| 16 | }) |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | window.onerror = function ( |
| 21 | _message, |
| 22 | _url, |
| 23 | _line, |
| 24 | _column, |
| 25 | errorObject |
| 26 | ) { |
| 27 | muestraError(errorObject) |
| 28 | return true |
| 29 | } |
| 30 | |
| 31 | window.addEventListener('unhandledrejection', event => { |
| 32 | muestraError(event.reason) |
| 33 | event.preventDefault() |
| 34 | }) |
| 35 | |