| 1 | import { exportaAHtml } from "./exportaAHtml.js" |
| 2 | import { ProblemDetails } from "./ProblemDetails.js" |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | export function muestraError(error) { |
| 10 | |
| 11 | if (error === null) { |
| 12 | |
| 13 | console.error("Error") |
| 14 | alert("Error") |
| 15 | |
| 16 | } else if (error instanceof ProblemDetails) { |
| 17 | |
| 18 | let mensaje = error.title |
| 19 | if (error.detail) { |
| 20 | mensaje += `\n\n${error.detail}` |
| 21 | } |
| 22 | mensaje += `\n\nCódigo: ${error.status}` |
| 23 | if (error.type) { |
| 24 | mensaje += ` ${error.type}` |
| 25 | } |
| 26 | |
| 27 | console.error(mensaje) |
| 28 | console.error(error) |
| 29 | console.error("Headers:") |
| 30 | error.headers.forEach((valor, llave) => console.error(llave, "=", valor)) |
| 31 | alert(mensaje) |
| 32 | |
| 33 | } else { |
| 34 | |
| 35 | console.error(error) |
| 36 | alert(error.message) |
| 37 | |
| 38 | } |
| 39 | |
| 40 | } |
| 41 | |
| 42 | exportaAHtml(muestraError) |