Esempio n. 1
0
 /**
  * Returns default error suffix
  * @param ERROR_RAISE_TEXT|ERROR_RAISE_HTML|ERROR_RAISE_ANSI format state
  *        that error message should be in
  * @param boolean If true, then return any context information.  By default,
  *                the source code is highlighted as PHP in HTML and returned
  *                or just returned as is in other states
  */
 function getErrorSuffix($state = ERROR_RAISE_TEXT, $context = false)
 {
     if ($context) {
         if (isset($this->backtrace)) {
             $this->_grabBacktrace();
         }
         if (isset($this->_file) && isset($this->_line)) {
             $context = Error_Util::getErrorContext($this->_file, $this->_line, $this->_contextLines);
             if ($state == ERROR_RAISE_HTML) {
                 return @highlight_string(trim($context['source']), true);
             } else {
                 $vars['context'] = trim($context['source']);
             }
             $suffix = "\n%context%\n";
             return Error_Raise::sprintfErrorMessageWithState($suffix, $vars, $state);
         }
     } else {
         return '';
     }
 }
Esempio n. 2
0
 /**
  * Error message generator for package HTML_Progress
  *
  * @param      integer   $code
  * @param      array     $args
  * @param      integer   $state
  *
  * @return     string
  * @since      1.0
  * @access     private
  */
 function _getErrorMessage($code, $args, $state)
 {
     $messages = array(HTML_PROGRESS_ERROR_INVALID_INPUT => 'invalid input, parameter #%paramnum% ' . '"%var%" was expecting ' . '"%expected%", instead got "%was%"', HTML_PROGRESS_ERROR_INVALID_CALLBACK => 'invalid callback, parameter #%paramnum% ' . '"%var%" expecting %element%,' . ' instead got "%was%" does not exists');
     if (isset($messages[$code])) {
         $message = $messages[$code];
     } else {
         $message = 'Code ' . $code . ' is not a valid error code';
     }
     return Error_Raise::sprintfErrorMessageWithState($message, $args, $state);
 }
Esempio n. 3
0
 /**
  * Get an error message for Error_Util errors
  * @return string error message from error code
  * @param integer
  * @param array
  * @static
  */
 function genErrorMessage($code, $args = array(), $state = ERROR_RAISE_TEXT)
 {
     if (!is_array($args)) {
         return 'Error: $args passed to Error_Util::genErrorMessage is ' . 'not an array but a ' . gettype($args);
     }
     $messages = array(ERROR_UTIL_ERROR_CLASS_DOESNT_EXIST => 'class "%cl%" does not exist', ERROR_UTIL_ERROR_INVALID_INPUT => 'invalid input, parameter #%paramnum% ' . '"%var%" was expecting ' . '"%expected%", instead got "%was%"', ERROR_UTIL_ERROR_METHOD_DOESNT_EXIST => 'method "%method%" doesn\'t exist in class "%class%"', ERROR_UTIL_ERROR_FUNCTION_DOESNT_EXIST => 'function "%function%" doesn\'t exist', ERROR_UTIL_ERROR_INTERNAL_FUNCTION => 'function "%function%" is an internal function, and ' . 'cannot be used as a callback');
     if (is_int($code) && isset($messages[$code])) {
         $msg = $messages[$code];
         return Error_Raise::sprintfErrorMessageWithState($msg, $args, $state);
     } else {
         return 'Error: code ' . $code . ' not found';
     }
 }
Esempio n. 4
0
 /**
  * Get an Error_Raise error message from a code
  *
  * This is the error message generator for the Error_Raise package, and
  * should not be used by other packages.  It can be used as an example
  * of one way to generate an error message
  * @access private
  * @return string error message from error code
  * @param integer
  * @param array
  * @static
  */
 function _getErrorMessage($code, $args = array(), $state = ERROR_RAISE_TEXT)
 {
     if (!is_array($args)) {
         return 'Error: $args passed to Error_Raise::_getErrorMessage is ' . 'not an array but a ' . gettype($args);
     }
     $messages = array(ERROR_RAISE_ERROR_CLASS_DOESNT_EXIST => 'class "%cl%" does not exist', ERROR_RAISE_ERROR_CODENOMSG => 'package "%package%" has no registered error message ' . 'generator', ERROR_RAISE_ERROR_ALREADY_INITIALIZED => 'package "%package%" has already been initialized', ERROR_RAISE_ERROR_INVALID_INPUT => 'invalid input, parameter #%paramnum% ' . '"%var%" was expecting ' . '"%expected%", instead got "%was%"', ERROR_RAISE_ERROR_INVALID_ERROR_CLASS => 'error class "%class%" in package ' . '"%package%," error type ' . '"%type%" does not descend from ' . 'Error_Raise_Error.  Use ' . 'PEAR::raiseError() for normal PEAR_Error classes', ERROR_RAISE_ERROR_INVALID_ERRMSGGEN => 'Invalid callback passed to setErrorMsgGenerator() for package' . ' %package%', ERROR_RAISE_ERROR_INVALID_CONTEXT_GRABBER => 'An invalid callback was passed as a context grabber for ' . 'package %package%', ERROR_RAISE_ERROR_INVALID_CONTEXTGRABBER_RETURN => 'The context grabber for package %package% did not return an ' . 'array, but instead returned a %type%');
     if (is_int($code) && isset($messages[$code])) {
         $msg = $messages[$code];
         return Error_Raise::sprintfErrorMessageWithState($msg, $args, $state);
     } else {
         return 'Error: code ' . $code . ' not found';
     }
 }