@justsml/

throwing-errors-in-javascript

Nodejs

using error constructor(s) correctly

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
const throwTypeError = () => {throw TypeError('error!')}
const throwStuff = () => {throw 'not real error, mate!'}

try { throwStuff() } catch (error) { console.log('No Stack: ❌', error) }
console.log('\n\n\n')
try { throwTypeError()  } catch (error) { console.log('Stacked: ✅', error) }

node v10.16.0