Why can't I just throw an Error inside the catch callback and let the process handle the error as if it were in any other scope?  If I don't do console.log(err) nothing gets printed out and I know nothing about what happened. The process ju...
I have a simple javascript package I'm trying to test. I want to check for an Error being thrown, but when my test is run, and the error is thrown, the test is marked as failing.  Here's the code:  var should = require('chai').should(...
I have a function attached to window.onerror   window.onerror = function(errorMsg, url, line) {                 window.alert('asdf');                 };";   This works fine in firefox, chrome and IE, but it doesn't work in safari. Fro...
Below throw code giving lint error Expected an object to be thrown no-throw-literal  throw { code : 403, message : myMessage };   if i try throw new Error, i am not getting eslint but it gives [Object Object] in the response.  throw new Error({ code...
What type of object should be thrown in JavaScript?   I see a lot of examples which throw a plain old string and there seems to be a semi-standard Error type. Should I prefer one over the other?...
I was reading the book Professional Javascript For Web Developers, and saw the following code. I have some questions about it:    What does "throw new Error()" return? Undefined?  What will happen to the code block of "if" if there is...
In Chrome, when an exception occurs, it prints a stack trace to the console log. This is extremely useful, but unfortunately in cases where an exception has been rethrown this causes an issue.  } catch (e) {     if (foo(e)) {         // handle the ex...
I'm trying to get my head around OOP in Javascript (I've never really used OOP in any other language either, so this is my first experience of it). I've written a class that requires an input for the constructor, but the constructor only...
in JS, you can throw a "new Error(message)", but if you want to detect the type of the exception and do something different with the message, it is not so easy.  This post:  http://www.nczonline.net/blog/2009/03/10/the-art-of-throwing-javascr...
I've seen 3 different ways of throwing an error in JavaScript:  throw 'message'; throw Error('message'); throw new Error('message');   What is the difference between them?  Note: I am aware of similar questions (1,2,3, etc...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.