Skip to content

Commit

Permalink
Características agregadas
Browse files Browse the repository at this point in the history
- Ahora los errores fatales son capturados por el error handler
- Modificación menor de estilos en la presentación de errores
  • Loading branch information
itsalb3rt committed Jul 19, 2019
1 parent 8df83a2 commit 2c3889a
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 48 deletions.
137 changes: 91 additions & 46 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 23 additions & 2 deletions Core/System/Core/errorHandler/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
* Captura los errores comunes que pueden ocurrir
* dentro de un proyecto, esto no manja todos los errores del framework ya que
* otras cosas especificas como errores al pasar un url
* o errore de archivo de vista son manejados desde el controlador
* o errores de archivo de vista son manejados desde el controlador
* principal
**/
*
* Maneja todos los errores faltales, warning, notice.
**/
class ErrorHandler
{

public function __construct()
{
set_error_handler([$this, 'errorHandler']);
register_shutdown_function( [$this,'fatalHandler'] );
}

public function errorHandler($errno, $errstr, $errfile, $errline)
Expand All @@ -24,6 +27,23 @@ public function errorHandler($errno, $errstr, $errfile, $errline)
}
}

public function fatalHandler() {
$errfile = "unknown file";
$errstr = "shutdown";
$errno = E_CORE_ERROR;
$errline = 0;

$error = error_get_last();

if( $error !== NULL) {
$errfile = $error["file"];
$errline = $error["line"];
$errstr = $error["message"];
$file_without_root_dir = str_replace(str_replace(DS,'\\',ROOT),'',$errfile);
__show_dev_messages__(substr($errstr,0,50) . '...' , "<p class='error-description'>$errstr</p> " . $file_without_root_dir . " <span class='code'>on line $errline</span>");
}
}

private function is_notice($errno){
switch ($errno){
case E_NOTICE:
Expand All @@ -50,4 +70,5 @@ private function is_fatal_error($errno){
return true;
}
}

}
10 changes: 10 additions & 0 deletions Core/System/Core/pages_messages/Views/code_messages/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,16 @@
border: 1px solid rgb(225, 225, 225);
border-radius: 4px;
}
.error-description{
padding: .2rem .5rem;
margin: 10px .2rem;
font-size: 85%;
background: rgb(241, 241, 241);
border: 1px solid rgb(225, 225, 225);
border-radius: 4px;
line-height: 1.8em;
}

ul li {
margin: 8px auto;
}
Expand Down

0 comments on commit 2c3889a

Please sign in to comment.