Source for file Ethna_Error.php
Documentation is available at Ethna_Error.php
// vim: foldmethod=marker
* @author Masaki Fujimoto <fujimoto@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
// {{{ ethna_error_handler
* @param int $errno エラーレベル
* @param string $errstr エラーメッセージ
* @param string $errfile エラー発生箇所のファイル名
* @param string $errline エラー発生箇所の行番号
$php_errno =
'Fatal error'; break;
$php_errno =
'Warning'; break;
$php_errno =
'Parse error'; break;
$php_errno =
'Notice'; break;
$php_errno =
'Unknown error'; break;
$php_errstr =
sprintf('PHP %s: %s in %s on line %d',
$php_errno, $errstr, $errfile, $errline);
$logger =
& $c->getLogger();
$logger->log($level, sprintf("[PHP] %s: %s in %s on line %d",
$name, $errstr, $errfile, $errline));
$config =
& $c->getConfig();
$is_debug =
$config->get('debug');
$facility =
$logger->getLogFacility();
?
in_array('echo', $facility) :
$facility ===
'echo';
if ($is_debug ==
true &&
$has_echo ===
false) {
$format =
"<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n";
$format =
"%s: %s in %s on line %d\n";
printf($format, $php_errno, $errstr, $errfile, $errline);
// {{{ ethna_exception_handler
// TODO: Implement ethna_exception_handler function.
* @author Masaki Fujimoto <fujimoto@php.net>
/** @var object Ethna_I18N i18nオブジェクト */
/** @var object Ethna_Logger loggerオブジェクト */
/** @var string エラーメッセージ */
/** @var integer エラーコード */
/** @var integer エラーモード */
/** @var array エラーモード依存のオプション */
/** @var string ユーザー定義もしくはデバッグ関連の追加情報を記した文字列。 */
* $userinfo は第5引数に設定すること。
* @param string $message エラーメッセージ
* @param int $code エラーコード
* @param int $mode エラーモード(Ethna_Errorはコールバックを
* @param array $options エラーモード依存のオプション
* @param array $userinfo エラー追加情報($options より後の全ての引数)
* @see http://pear.php.net/manual/ja/core.pear.pear-error.pear-error.php
function Ethna_Error($message =
null, $code =
null, $mode =
null, $options =
null)
if ($controller !==
null) {
$this->i18n =
& $controller->getI18N();
// $options 以降の引数 -> $userinfo
if (count($userinfo) ==
1) {
$this->userinfo =
$userinfo[0];
} else if (is_null($userinfo[0])) {
$this->userinfo =
array();
$this->userinfo =
$userinfo[0];
$this->userinfo =
array();
$message =
$controller->getErrorMessage($code);
$message =
'unknown error';
$this->message =
$message;
$this->options =
$options;
$this->level =
($this->options ===
NULL) ?
E_USER_NOTICE :
$options;
// Ethnaフレームワークのエラーハンドラ(callback)
* エラーオブジェクトに関連付けられたエラーコードを返します。
* @return integer - エラー番号
* - $userinfoとして渡されたデータによるvsprintf()処理
* @return string エラーメッセージ
$tmp_message =
$this->i18n ?
$this->i18n->get($this->message) :
$this->message;
$tmp_userinfo =
to_array($this->userinfo);
$tmp_message_arg_list =
array();
for ($i =
0; $i <
count($tmp_userinfo); $i++
) {
$tmp_message_arg_list[] =
$this->i18n ?
$this->i18n->get($tmp_userinfo[$i]) :
$tmp_userinfo[$i];
return vsprintf($tmp_message, $tmp_message_arg_list);
* エラー追加情報配列の個々のエントリへのアクセスをサポート
* @param int $n エラー追加情報のインデックス(省略可)
* @return mixed message引数
if (isset
($this->userinfo[$n])) {
return $this->userinfo[$n];
* @param string $info 追加するエラー情報
$this->userinfo[] =
$info;
Documentation generated on Fri, 11 Nov 2011 03:59:42 +0900 by phpDocumentor 1.4.3