"use strict";
/**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
* @created 2020-05-17
* @modified
*
* @description async /await errorCaptured
* @augments
* @example
* @link
*
*/
const log = console.log;
async function errorCaptured(asyncFunc, placeholder = null, debug = false) {
try {
const asyncData = await asyncFunc();
if(debug) {
log(`asyncData =`, asyncData);
}
return [placeholder, asyncData];
} catch (error) {
return [error, placeholder];
}
};
const errorCaptured = async (asyncFunc, placeholder = null, debug = false) => {
try {
const asyncData = await asyncFunc();
if(debug) {
log(`asyncData =`, asyncData);
}
return [placeholder, asyncData];
} catch (error) {
return [error, placeholder];
}
};
export default errorCaptured;
export {
errorCaptured,
};
Created
May 17, 2020 17:02
-
-
Save xgqfrms/7313acccc6f4f35b00a253b0f8877bee to your computer and use it in GitHub Desktop.
async /await errorCaptured
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://juejin.im/post/5d25b39bf265da1bb67a4176