ircbot/Testcode/Misc/Exceptions.php

61 lines
854 B
PHP
Raw Permalink Normal View History

2010-11-21 23:48:11 +01:00
<?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);
}
?>