Last active
April 7, 2023 12:19
-
-
Save darkmavis1980/ced312027a913355578c84bf3ff94ead to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const asyncFn = () => Promise.reject(new Error("async fn error", { | |
cause: { | |
type: 'FirstErrorCause' | |
} | |
})); | |
const asyncManipulateResponse = (response) => Promise.resolve("manipulated response"); | |
const tryCatchFn = async () => { | |
try { | |
const response = await asyncFn(); | |
const manipulatedResponse = await asyncManipulateResponse(response); | |
return manipulatedResponse; | |
} catch (e) { | |
if (e.cause.type === 'FirstErrorCause') { | |
console.error("readable contextualized response error messag") | |
} | |
console.error(e); | |
} | |
}; | |
tryCatchFn(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment