Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created August 7, 2017 19:53
Show Gist options
  • Save prof3ssorSt3v3/fd21ab75e9c6eff18818eb19594cef49 to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/fd21ab75e9c6eff18818eb19594cef49 to your computer and use it in GitHub Desktop.
//throwing Errors and Exceptions
//and
//using Try...Catch to handle thrown Errors and Exceptions
//Error Types:
// EvalError, InternalError, RangeError, ReferenceError,
// SyntaxError, TypeError, URIError
try{
//throw 'Javelin';
//throw {name:'Bubba', message:'Salmon'};
let url = "http://jsonplaceholder.typicode.com";
fetch(url).then((response)=>{})
//throw new Error('A stick');
console.log('Hello');
}catch(err){
console.log('Caught', err.name, err.message);
}finally{
console.log('Took you a long time');
}
console.log('end');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment