Creato da pastuweb.com
Share My Page
My Social Accounts
Account FaceBook Account LinkedIn Account Twitter Account Google Plus Account Git Hub

What is an Exception?

  • an exceptionsl event
  • error that occur at runtime
  • the cause of alteration in the normal program

When an exception occurs in a method, you crate an object of type exception and returned to the runtime system.

Creating an exception obect and return it to the runtime system is called "throwing an exceptio". The exception object contains information about the error, including the type and state of the program when the error occurred. The runtime systems runs through the stack of calls in search of handler for the exception.

When an appropriate handler has been found, the system runtime passes the exception to the handler.

  • An handler is considered appropriate if the type exception thrown matches the type that can be handled by the operator
  • Let's just say that the handler catches the exception

If the runtime system runs through the call stack without finding an appropriate handler, the runtime system ( and Consequently , the program ) terminates the search and uses the default handler.

Using try/catch:

try{

code to check

}catch(<Exception type> <Object name>){

code to manage exception

}

Average (1 Vote)
The average rating is 5.0 stars out of 5.