In questo tutorial imparerete come gestire tipologie diverse di eccezioni!
class FooException extends Exception {
public function __construct($message = null, $code = 0) {
// do something
}
}
class BarException extends Exception {
public function __construct($message = null, $code = 0) {
// do something
}
}
class BazException extends Exception {
public function __construct($message = null, $code = 0) {
// do something
}
}
try {
// some code that might trigger a Foo/Bar/Baz/Exception
}
catch(FooException $e) {
// we caught a foo exception
}
catch(BarException $e) {
// we caught a bar exception
}
catch(BazException $e) {
// we caught a baz exception
}
catch(Exception $e) {
// we caught a normal exception
// or an exception that wasn’t handled by any of the above
}
fonte: www.sastgroup.com





