FactoryController.prototype.create=function(callback){//The throw is working, and the exception is returned.thrownewError('An error occurred');//outside callback try{this.check(function(check_result){callback(check_result);});}catch(ex){thrownewError(ex.toString());}}FactoryController.prototype.create=function(callback){try{this.check(function(check_result){//The throw is not working on this case to return the exception to the caller(parent)thrownewError('An error occurred');//inside callback });}catch(ex){thrownewError(ex.toString());}}
ErrorNameDescriptionEvalErrorAn error in the eval()function has occurred.RangeErrorOutof range number value has occurred.ReferenceErrorAn illegal reference has occurred.SyntaxErrorA syntax error within code inside the eval()function has occurred.All other syntax errors are not caught by try/catch/finally, and will
trigger the default browser error message associated with the error.Tocatch actual syntax errors, you may use the onerror event.TypeErrorAn error in the expected variable type has occurred.URIErrorAn error when encoding or decoding the URI has occurred(ie: when calling encodeURI()).
try{//something that causes an error}catch(ex){if(ex instanceofTypeError){//handle the error}elseif(ex instanceofReferenceError){//handle the error}else{//handle all others}}