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...
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'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...
I know the use of next() method which advance the iterator to the next position of yield keyword and return the object which contains the result of yield expression, like this:     yield double(40); => call iterator.next() would return something l...
I would like to create a function that returns a promise and if something throws an error within, it returns promise reject.  function promiseFunc(options) {   return new Promise(() => {     return options;   }); }  function myfunc(options) {   re...
If I have following   function ValidationException(nr, msg){    this.message = msg;    this.name = "my exception";    this.number = nr; } function myFunction(dayOfWeek){    if(dayOfWeek > 7){       throw new ValidationException(dayOfWeek,...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.