ejecuta()
function fnExito(resolve, reject) {
setTimeout(
() => resolve("Hola"),
5000)
}
function fnFalla(resolve, reject) {
setTimeout(
() => reject(new Error("ouch")),
5000)
}
async function ejecuta() {
try {
const r1 =
await new Promise(fnExito)
console.log("Éxito 1", r1)
} catch (e) {
console.
log("Falló 1:", e.message)
}
try {
const r2 =
await new Promise(fnFalla)
console.log("Éxito 2:", r2)
} catch (e) {
console.
log("Falló 2:", e.message)
}
}