ircbot/Testcode/Misc/Exceptions.php
Jan Philipp Timme 952af43b97
2010-11-21 22:48:11 +00:00

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);
}
?>