Skip to content

关于throw new Error()抛出错误的捕获catch问题 #202

Description

@ckinmind
// 抛出错误
throw new Error('这是错误原因')

// 捕获错误
try {
    
} catch (error) {
    if (error.message === '这是错误原因') {
        // 捕获某个错误
    }
}

注意这里是error.message

参考资料

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions