Example #1
0
 /**
  * Retrieve the error message for this object
  *
  * Error messages are dynamically generated from the callback
  * set by {@link Error_Raise::initialize()}, or passed to
  * {@link Error_Raise::setErrorMsgGenerator()}.  The function is passed the
  * error code, user information that was set in the constructor, and the
  * display state, and must return a string.
  *
  * An example error message generator is Error_Raises's own generator
  * found at {@link Error_Raise::_getErrorMessage()}
  * @uses getErrorPrefix() grab the error prefix generated dynamically
  *       from context information
  * @return string
  * @throws ERROR_RAISE_ERROR_CODENOMSG if no error message generator
  *         function has been registered for this package
  * @param ERROR_RAISE_TEXT|ERROR_RAISE_HTML|ERROR_RAISE_ANSI format state
  *        that error message should be in
  * @param boolean determines whether source code context is displayed with
  *        the message.  By default, the presence of a context grabbing
  *        function sets this to true.  Pass in true to turn off context
  *        display
  */
 function getMessage($state = ERROR_RAISE_TEXT, $context = false)
 {
     $package = $this->_package;
     if (isset($GLOBALS['_ERROR_RAISE_MSGS'][$package])) {
         if (function_exists('debug_backtrace')) {
             $e = $this->_grabBacktrace($this->backtrace, $this, $this->_type);
             if (PEAR::isError($e)) {
                 return $e;
             }
         }
         $this->error_message_prefix = $this->getErrorPrefix($state, $context);
         $this->message = $this->getBareMessage($state);
         $this->error_message_suffix = $this->getErrorSuffix($state, $context);
         return $this->error_message_prefix . $this->message . $this->error_message_suffix;
     } else {
         $e = Error_Raise::warning('error_Raise', ERROR_RAISE_ERROR_CODENOMSG, array('package' => $package));
         if (strlen($this->message)) {
             return parent::getMessage();
         }
         return $e->getMessage($state);
     }
 }