| 1 | export class ProblemDetailsError extends Error { |
| 2 | |
| 3 | /** |
| 4 | * Detalle de los errores devueltos por un servicio. |
| 5 | * Crea una instancia de ProblemDetailsError. |
| 6 | * @param {any} problemDetails Objeto con la descripcipon del error. |
| 7 | */ |
| 8 | constructor(problemDetails) { |
| 9 | |
| 10 | super( |
| 11 | typeof problemDetails["detail"] === "string" |
| 12 | ? problemDetails["detail"] |
| 13 | : ( |
| 14 | typeof problemDetails["title"] === "string" |
| 15 | ? problemDetails["title"] |
| 16 | : "Error" |
| 17 | ) |
| 18 | ) |
| 19 | |
| 20 | this.problemDetails = problemDetails |
| 21 | |
| 22 | } |
| 23 | |
| 24 | } |