Standardize error handling
async function awesome() {
try {
const data = await promise;
return [data, null]
} catch(error) {
console.error(error)
return [null, error];
}
}
Using it
async function main() {
const [data1, error] = await awesome();
const [data2, error] = await awesome();
// #- ...
}