exception.thumbnail

In normal desktop applications , we use exception handling everywhere in our
code.
But in server side script such as php, we can limit the usage of Exception handling.

Example for raising an exception in php

//create function with an exception

function checkValue($number)
{

if($number>4)
throw new
Exception(“Value must be 4 or below“);

return true

}

//trigger exception
checkValue(5);

?>

The above code will give : Fatal error: Uncaught exception ‘Exception’

If we call like this:

try{

checkValue(5);

}

catch(Exception $e)

{
echo ‘Message: ‘ .$e->getMessage();

}

?>

The code above will get an error like this:

Message: Value must be 4 or below