草庐IT

m_someObject

全部标签

javascript - `throw new Error` 和 `throw someObject` 有什么区别?

我想编写一个通用错误处理程序,它可以捕获在任何代码实例中故意抛出的自定义错误。当我thrownewError('sample')像下面的代码一样try{thrownewError({'hehe':'haha'});//thrownewError('hehe');}catch(e){alert(e);console.log(e);}日志在Firefox中显示为Error:[objectObject],我无法解析该对象。对于第二个throw,日志显示为:Error:hehe而当我这样做时try{throw({'hehe':'haha'});}catch(e){alert(e);consol
12