日期:2014-05-16  浏览次数:20300 次

写了一个抛出异常的函数,欢迎拍砖
写了一个小函数,抛出异常时输出调用顺序。刚开始学习JavaScript,欢迎指正!
JScript code
function throwMyError(name,message){
    //output the call stack
    console.trace();
    var err = new Error();
    err.name = name;
    err.message = message;
    throw(err);
}


------解决方案--------------------
throw {message:'error'};