PEAR::raiseError

sanya_php

Новичок
PEAR::raiseError

Глобально установлен флаг
PEAR_ERROR_DIE

Хочу некоторые ошибки чтобы обрабатывались а скрипт не умирал.

Делаю так:
PHP:
        PEAR::setErrorHandling(PEAR_ERROR_PRINT);
        if(PEAR::isError($e = File::readAll($file))){
            $this->raiseError('Cant find file');
        } else {
            $this->_array = @unserialize($e);    
        }
        PEAR::setErrorHandling(PEAR_ERROR_DIE);
(raiseError переопределена у меня в классе)


Может есть что-то красивей ?
 

Sad Spirit

мизантроп (Старожил PHPClub)
Команда форума
pushErrorHandling() / popErrorHandling() будут слегка красивей.
 

sanya_php

Новичок
но это с новым обработчиком. А я пока использую классы где старый обработчик ошибок. PEAR_Error простой
 

Sad Spirit

мизантроп (Старожил PHPClub)
Команда форума
Автор оригинала: sanya_php
но это с новым обработчиком. А я пока использую классы где старый обработчик ошибок. PEAR_Error простой
Ну, это методы класса PEAR как раз для работы с PEAR_Error.
 

neonet

Новичок
Помогите разобраться пожалуйста, у меня такая проблема(

Unknown error: Declaration of XML_Parser::raiseError() should be compatible with that of PEAR::raiseError() in /home/nnn/data/www/nnnu/sys/pear/XML/Parser.php on line 634

File PEAR.php
PHP:
function &raiseError($message = null,
                         $code = null,
                         $mode = null,
                         $options = null,
                         $userinfo = null,
                         $error_class = null,
                         $skipmsg = false)
    {
        // The error is yet a PEAR error object
        if (is_object($message)) {
            $code        = $message->getCode();
            $userinfo    = $message->getUserInfo();
            $error_class = $message->getType();
            $message->error_message_prefix = '';
            $message     = $message->getMessage();
        }

        if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
            if ($exp[0] == "*" ||
                (is_int(reset($exp)) && in_array($code, $exp)) ||
                (is_string(reset($exp)) && in_array($message, $exp))) {
                $mode = PEAR_ERROR_RETURN;
            }
        }
        // No mode given, try global ones
        if ($mode === null) {
            // Class error handler
            if (isset($this) && isset($this->_default_error_mode)) {
                $mode    = $this->_default_error_mode;
                $options = $this->_default_error_options;
            // Global error handler
            } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
                $mode    = $GLOBALS['_PEAR_default_error_mode'];
                $options = $GLOBALS['_PEAR_default_error_options'];
            }
        }

        if ($error_class !== null) {
            $ec = $error_class;
        } elseif (isset($this) && isset($this->_error_class)) {
            $ec = $this->_error_class;
        } else {
            $ec = 'PEAR_Error';
        }
        if ($skipmsg) {
            $a = new $ec($code, $mode, $options, $userinfo);
            return $a;
        } else {
            $a = new $ec($message, $code, $mode, $options, $userinfo);
            return $a;
        }
    }
File Parser.php
PHP:
function raiseError($msg = null, $ecode = 0)
    {
        $msg = !is_null($msg) ? $msg : $this->parser;
        $err = new XML_Parser_Error($msg, $ecode);
        return parent::raiseError($err);
    }

Не выкупаю.. что с чем не совместимо?
 
Сверху