(a, b)
| 54 | // throw new Error("Se ha producido un error") |
| 55 | |
| 56 | function sumIntegers(a, b) { |
| 57 | if (typeof a !== "number" || typeof b !== "number") { |
| 58 | throw new TypeError("Esta operación sólo suma números") |
| 59 | } |
| 60 | if (!Number.isInteger(a) || !Number.isInteger(b)) { |
| 61 | throw new Error("Esta operación sólo suma números enteros") |
| 62 | } |
| 63 | if (a == 0 || b == 0) { |
| 64 | throw new SumZeroIntegerError("Se está intentando sumar cero", a, b) |
| 65 | } |
| 66 | return a + b |
| 67 | } |
| 68 | |
| 69 | try { |
| 70 | console.log(sumIntegers(5, 10)) |