I throw an Error using the Error() object in a simplified function like so:
function errorExample() {
try {
throw new Error('ConnectionError', 'cannot connect to the internet')
}
catch(error) {
console.log(error
}
}
I want to be able to access the error name and message from within the catch statement.
According to Mozilla Developer Network I can access them through error.proptotype.name and error.proptotype.message however with the code above I receive undefined.
Is there a way to do this? Thanks.