Test error

by amrendra kumar

JavaScript

const tryCatchTest = () => {
  throw new Error('testing error')
}

const thisFunctionCatchAndDoesNotThrow = () => {
	try {
  	tryCatchTest()
  } catch(error) {
  	//error should not thrown from top stack function
  	console.log('error', error)
  }
}

thisFunctionCatchAndDoesNotThrow();



const thisFunctionCatchAndThrowError = () => {
	try {
  	tryCatchTest()
  } catch(error) {
  	// it will be uncought error  shoudl not throw from here
  	throw error
  }
}

thisFunctionCatchAndThrowError()


const test = 5
console.log('this code will never run because of above uncaught error', test)