Source for file BaseException.class.php
Documentation is available at BaseException.class.php
* @copyright Energine 2006
//require_once('core/framework/DBWorker.class.php');
//require_once('core/framework/Transformer.class.php');
//require_once('core/framework/Response.class.php');
//require_once('core/framework/Mail.class.php');
//require_once('core/framework/Language.class.php');
* XSLT-документ для страницы ошибки
* Ошибка 404 - страницы не существует
* Ошибка 403 - нет прав на просмотр страницы
* Ошибка разработчика, где-то что-то неверно написано :)
* Ошибка, связанная с мультиязычностью. Возникает при обработке другой
* ошибки и отсутствия для неё переводов. Без ERR_LANG возможет уход
* в рекурсию и полный пиздец.
* Данная ошибка касается исключительно разработчиков системы.
* @todo сделать хоть что-нибудь! :)
* Когда режим отладки включен:
* 1. Можно вывести XML-документ страницы добавив к query-части URI
* 2. При обработке системных ошибок выводится максимально подробная
* информация о возникшей ошибке.
* @var boolean флаг режима отладки
* @var Response экземпляр объекта Response
* @var boolean флаг режима вывода XML-документа страницы
* @var mixed дополнительная информация об ошибке
* @param mixed $customMessages
* @todo определиться с $customMessages: это mixed или array?
public function __construct($message, $code = self::ERR_CRITICAL, $customMessages = null) {
$this->isXML = isset ($_GET['debug']);
$this->doc = new DOMDocument('1.0', 'UTF-8');
if (isset ($customMessages)) {
if ($code == self::ERR_LANG) {
elseif ($code == self::ERR_403) {
elseif ($code == self::ERR_404) {
elseif ($code != self::ERR_DB ) {
parent::__construct($message, $code);
* Возвращает дополнительную информацию об ошибке.
* @todo переименовать в getCustomMessages
* Отправляет уведомление о ошибке
$body = sprintf("Project:%s\r\nCode:%s\r\nMessage:%s\r\nCustomMessage:%s\r\n,File:%s\r\nLine:%s\r\nTrace:%s", $projectName, $this->getCode(), $this->getMessage(), $customMessage,$this->getFile(), $this->getLine(), $this->getTraceAsString());
->setSubject($projectName. ' Error Notification:'. $this->getMessage())
* Формирует XML-представление ошибки.
protected function build() {
$dom_errors = $this->doc->createElement('errors');
$dom_errors->setAttribute('uri', $request->getPath(Request::PATH_WHOLE, true));
$dom_errors->setAttribute('base', $request->getBasePath());
$dom_error = $this->doc->createElement('error');
$dom_error->setAttribute('code', $this->getCode());
$dom_error->setAttribute('file', $this->getFile());
$dom_error->setAttribute('line', $this->getLine());
$this->doc->createElement('message', $this->getMessage())
$dom_customMessages = $this->doc->createElement('customMessages');
foreach ($customMessages as $customMessage) {
$dom_customMessages->appendChild(
$this->doc->createElement('customMessage', $customMessage)
$dom_customMessages->nodeValue = $customMessages;
$dom_error->appendChild($dom_customMessages);
$dom_errors->appendChild($dom_error);
$this->doc->appendChild($dom_errors);
* Обрабатывает ошибку путём её вывода :)
if (!in_array($this->getCode(), array(self::ERR_403, self::ERR_404, self::ERR_NOTICE, self::ERR_WARNING)) && !$this->isDebugEnabled) {
$result = $this->doc->saveXML();
$result = $transformer->transform($this->doc, self::ERROR_TRANSFORMER);
|