Skip to content

Commit

Permalink
Update Exception.php
Browse files Browse the repository at this point in the history
Removendo exibição da mensagem de erro, para que fique a cargo da aplicação exibir a mensagem caso a exceção não seja tratada
  • Loading branch information
Tayron Miranda authored Jun 1, 2017
1 parent 8112331 commit 618166b
Showing 1 changed file with 2 additions and 31 deletions.
33 changes: 2 additions & 31 deletions Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Tayron\Request;
use Tayron\Template;

/**
* Classe de Exceção que gera log das exceções lançadas
Expand All @@ -28,7 +26,6 @@ public function __construct($message, $trace = true)
parent::__construct($message, 0, null);

$this->writeLog($message, $trace);
$this->showErroMessage($message, $trace);
}

/**
Expand All @@ -45,36 +42,10 @@ private function writeLog($message, $trace = true)
{
$listaParametroObjeto = explode('\\', get_class($this));
$nomeExcecao = end($listaParametroObjeto);
$trace = ($trace) ? $this->getTrace() : array();
$traceMessage = ($trace) ? $this->getTrace() : array();

$logger = new Logger($nomeExcecao);
$logger->pushHandler(new StreamHandler("logs/{$nomeExcecao}.log", Logger::WARNING));
$logger->addError(strip_tags(str_replace('<br />', ' | ', $message)), $trace);
}

/**
* Exception::showErroMessage
*
* Exibe mensagem de erro para o usuario
*
* @param string $message Mensagem personalizada de erro
* @param string $trace Ativa ou desativa a exibiçaõ de trance do erro
*
* @return void
*/
private function showErroMessage($message, $trace = true)
{
$message .= ($trace) ? '<br /><br /><pre>' . $this->getTraceAsString() . '</pre>' : null;
$request = Request::getInstance();

$pathView = PATH . DS . 'src' . DS . 'view';
$pathTemplate = PATH . DS . 'src' . DS . 'view' . DS . 'template';
$pathElements = PATH . DS . 'src' . DS . 'view' . DS . 'elements';

$this->template = Template::getInstance(null, $request, $pathView, $pathTemplate, $pathElements);

$this->template->setTemplate('error');
$this->template->setParameters(array('mensagem' => $message ));
$this->template->render('exceptions/error');
$logger->addError(strip_tags(str_replace('<br />', ' | ', $message)), $traceMessage);
}
}

0 comments on commit 618166b

Please sign in to comment.