Exception handling

An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions.

Types of exceptions

  • Checked exception
  • Error
  • Runtime exception
  1. Checked exceptions are checked at compile time. If a code throws a checked exception, then the associated block or method must handle the exception. For example, FileNotFoundException is a checked exception. If a method creates the FileInputStream object to read data from, a file must handle FileNotFoundException. If the specified file does not exist, then FileNotFoundException occurs and this exception must be caught or thrown.
  2. Errors are exceptional conditions that are external to the application and it's not possible to anticipate and ...

Get Learning Selenium Testing Tools - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.