This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?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);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user