ECMAScript proposal: Error cause (chaining errors) All In One
ECMAScript proposal: Error cause (chaining errors) All In One
function readFiles(filePaths) {
return filePaths.map(
(filePath) => {
try {
const text = readText(filePath);
const json = JSON.parse(text);
return processJson(json);
} catch (error) {
// (A)
}
});
}
throw new Error(error info =
, {cause: error});
function readFiles(filePaths) {
return filePaths.map(
(filePath) => {
try {
// ···
} catch (error) {
// ✅
throw new Error(`While processing ${filePath}`, {cause: error});
}
});
}
refs
https://2ality.com/2021/06/error-cause.html
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/14927901.html
未经授权禁止转载,违者必究!