Try, Catch, Error Flashcards
The ___________ statement lets you to test a code for possible errors. Place the code within the opening and closing braces. When any error occurs, it will be passed on to the catch statement.
try { }
The ______ statement lets you handle the error. The catch is executed only when an error occurs. You can program what to do if an error occurs
catch()
The argument received by the catch (i.e. catch(error)) is a JavaScript ________
ErrorObject
what key word to throw an error
THROW
The ________ statement marks a block of statements to try, and specifies a response, should an exception be thrown
try…catch
throw “error!”;
console.log(“hello”); //
does not run, stops at throw
try {
throw “error right here me i am here!”;
} catch(err){
console.log(“caught”, err);
}
console.log(“hello”);
//returns
caught error right here me i am here!
hello
try {
throw “error right here me i am here!”;
console.log(“hello”);
} catch(err){
console.log(“caught”, err);
}
//returns
caught error right here me i am here!
__________ that are executed after the try statement completes. These statements execute regardless of whether an exception was thrown or caught.
Finally Statements
try { //throw "error right here me i am here!"; console.log("hello");
} catch(err){ console.log("caught", err); } finally { console.log("took you a while"); } //returns and why
hello
took you a while
the catch is skipped as there was no error
The ______ constructor creates an error object.
error
How many errors are there
7
try {
console.logw(“hello”);
} catch(err){ // throw a new error object here }
throw new Error (//message);
in _____ there is no fetch method
Node