当前位置: 代码迷 >> JavaScript >> 写了一个抛出错误的函数,欢迎拍砖
  详细解决方案

写了一个抛出错误的函数,欢迎拍砖

热度:66   发布时间:2012-06-13 12:30:18.0
写了一个抛出异常的函数,欢迎拍砖
写了一个小函数,抛出异常时输出调用顺序。刚开始学习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'};
  相关解决方案