Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript Rethrow an Exception

const number = 5;
try {
     // user-defined throw statement
     throw new Error('This is the throw');
}
catch(error) {
    console.log('An error caught');
    if( number + 8 > 10) {

        // statements to handle exceptions
         console.log('Error message: ' + error); 
        console.log('Error resolved');
    }
    else {
        // cannot handle the exception
        // rethrow the exception
        throw new Error('The value is low');
    }
}
 
PREVIOUS NEXT
Tagged: #javascript #Rethrow #Exception
ADD COMMENT
Topic
Name
9+8 =