Alchemy University 学习教程,第一大块:Intermediate JavaScript Features  2
January 1st, 2023

估值102亿融资5.45亿的Alchemy 项目,大学每周任务逐步开始。持有大学生早期卡的地址可以进入以下官网,开始大学生活:

接下来我们学习 Exceptions 的课程。

1: Throw an Error

查看要求,需要抛出一个错误:

输入:

function throwError() {
    throw new Error("ee error !!.");
}

module.exports = throwError;

2: Catch An Error

查看要求,需要捕获一个错误:

输入:

function catchError(fn) {
    try {
        fn();
    } catch (ex) {
        console.log(ex);
    }
}

module.exports = catchError;

3: Return Error

查看要求,在2的基础上返回错误:

输入:

function catchError(fn) {
    try {
        fn();
    } catch (ex) {
        return ex;
    }

    return false;
}

module.exports = catchError;

点击运行。

4: Start an Error

查看要求:

输入:

function startError() {
    let abc;

    abc.prop;
}

module.exports = startError;

点击运行。

以上Exceptions 的学习完成。

未完待续......

了解更多,请关注作者:https://twitter.com/bitc2024

Subscribe to andrecronje
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.
More from andrecronje

Skeleton

Skeleton

Skeleton