9951 explained code solutions for 126 technologies


pythonHow to raise exception


if True:
  raise Exception('Error')ctrl + c
if True

condition to raise exception upon

raise

will throw specified exception

Exception

class of exception to raise (could be anything derived from Exception)

'Error'

error message to throw