Skip to content

Instantly share code, notes, and snippets.

@gad0lin
Last active November 15, 2017 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gad0lin/ff4f5b6650a293aec338e759ea161eff to your computer and use it in GitHub Desktop.
Save gad0lin/ff4f5b6650a293aec338e759ea161eff to your computer and use it in GitHub Desktop.
errors catching async
let b = async function() {
throw "bad"
}
let a = async function() {
try {
return b();
} catch (e) {
console.log(123)
}
}
let c = async function() {
try {
await a()
} catch (e) {
console.log("got it")
}
}
c()
function intervalFunc() {
console.log('Cant stop me now!');
}
setInterval(intervalFunc, 1500);
// output: got it and then cant stop me now
let b = async function() {
throw "bad"
}
let a = async function() {
return await b();
}
let c = async function() {
try {
await a()
} catch (e) {
console.log("got it")
}
}
c()
function intervalFunc() {
console.log('Cant stop me now!');
}
setInterval(intervalFunc, 1500);
// outpub: got it and can't stop me now
let b = async function() {
throw "bad"
}
let a = async function() {
try {
return await b();
} catch (e) {
console.log("aaa catch")
}
}
let c = async function() {
try {
await a()
} catch (e) {
console.log("got it")
}
}
c()
function intervalFunc() {
console.log('Cant stop me now!');
}
setInterval(intervalFunc, 1500);
// output: got it and can't stop me now
let b = async function() {
throw "bad"
}
let a = function() {
try {
return b();
} catch (e) {
console.log("aaa catch")
}
}
let c = async function() {
try {
await a()
} catch (e) {
console.log("got it")
}
}
c()
function intervalFunc() {
console.log('Cant stop me now!');
}
setInterval(intervalFunc, 1500);
// output: got it and can't stop me now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment