Error Handling - Javascript

  • Try-Catch works synchronously
  • Custom Error
    • throw new Error("statement")
    • throw new ReferenceError("statement")
  • If statement in try have error than it will send the error
        try {
            // statement
        } catch(err) {
            // err contains Error Object
            console.log(err.name)
            console.log(err.message)
            console.log(err.stack)
        } finally {
            // Runs in all cases, Used for cleanups
        }
    
Share: