[nycphp-talk] PHP 5 Exception Expertise Needed
Joseph Crawford
codebowl at gmail.com
Fri Mar 18 15:06:50 EST 2005
Jayesh,
I have attempted to do what you said i should try however i am still
getting the same results as i was before :(
<?php
/**
* The SvEx class
*
* This is the exception class for the main Application
*
* @author Joseph Crawford Jr. <codebowl at gmail.com>
* @copyright Codebowl Solutions 2005
* @package SimonVolkov
* @subpackage Exceptions
*
**/
class SvEx extends Exception {
protected $_msg;
protected $_tpl;
protected $_error = array(
'type' => "Unknown Error",
'description' => "There has been an error. This error has been
logged. Please try again in a few minutes."
);
public function __construct( $error = null ) {
$this->_tpl = Application::Template();
$this->_tpl->assign( 'error_type', $this->_error['type'] );
$this->_tpl->assign( 'error_description', $this->_error['description'] );
$this->_msg = $error;
parent::__construct($this->_msg);
}
public function Display($file, $line) {
$this->_tpl->assign('admin', 1);
$this->_tpl->assign('msg', $this->_msg);
$file = explode('\\', $file);
$top = count( $file ) - 1;
$file = '/' . $file[$top-1] . '/' . $file[$top];
$this->_tpl->assign('__FILE__', $file);
$this->_tpl->assign('__LINE__', $line);
$this->_tpl->display('error.tpl');
}
}
?>
<?php
/**
* The ApplicationEx class
*
* This is the exception class for the main Application class
*
* @author Joseph Crawford Jr. <codebowl at gmail.com>
* @copyright Codebowl Solutions 2005
* @package SimonVolkov
* @subpackage Exceptions
*
**/
class ApplicationEx extends SvEx {
public function __construct( $msg = null ) {
parent::__construct($msg);
$this->_error['type'] = "Application Error";
$this->_error['description'] = "An Application Error!";
}
}
?>
<?php
if( ( isset( $dbinfo['type'] ) && $dbinfo['type'] != "" ) && ( isset(
$dbinfo['host'] ) && $dbinfo['host'] != "" ) && ( isset(
$dbinfo['database'] ) && $dbinfo['database'] != "" ) ) {
self::$_db = new $dbinfo['type']($dbinfo['host'],
$dbinfo['database'], $dbinfo['user'], $dbinfo['pass']);
} else {
throw new ApplicationEx("Could not instanciate the database
object, you must specify the database type, hostname and database
name.");
}
?>
i am not sure why however the values for the error_type and
description are not getting set from the applicationEx class
--
Joseph Crawford Jr.
Codebowl Solutions
codebowl at gmail.com
More information about the talk
mailing list