61 lines
854 B
PHP
61 lines
854 B
PHP
<?php
|
|
|
|
class TestException extends Exception{
|
|
|
|
function __construct($message) {
|
|
$this->message = $message;
|
|
}
|
|
|
|
}
|
|
|
|
class TestFailException extends Exception {
|
|
|
|
function __construct($msg) {
|
|
$this->message = "Error: ".$msg;
|
|
}
|
|
|
|
}
|
|
|
|
class Service_ExceptionTest {
|
|
|
|
function __construct() {
|
|
|
|
}
|
|
|
|
public function TestTheFail() {
|
|
$this->failAtThis();
|
|
}
|
|
|
|
public function CatchAndThrow() {
|
|
try {
|
|
$this->failAtThis();
|
|
}
|
|
catch (Exception $e) {
|
|
throw new TestFailException("moep:D");
|
|
}
|
|
}
|
|
|
|
|
|
public function internalCatch() {
|
|
try {
|
|
$this->failAtThis();
|
|
}
|
|
catch (Exception $e) {
|
|
var_dump($e);
|
|
}
|
|
}
|
|
|
|
function failAtThis() {
|
|
throw new TestException("I had to do this. Please forgive me :/");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
try {
|
|
$ExceptionTest = new Service_ExceptionTest;
|
|
$ExceptionTest->CatchAndThrow();
|
|
} catch (Exception $e){
|
|
var_dump($e);
|
|
}
|
|
?>
|