Overview

Packages

  • Auth
  • Config
  • Controller
  • Date
  • Db
  • Feed
    • Abstract
    • Writers
  • File
    • Decorator
  • Form
    • Element
  • Image
  • Log
    • Writer
  • Net
    • Exception
  • None
  • PHP
  • PHPMailer
  • Session
  • Util
  • Validate
    • Validator
  • Zend
    • Registry

Classes

  • Util_Bench
  • Util_ErrorHandler
  • Util_Pagination
  • Util_String
  • Util_Token
  • Util_UserAgent

Exceptions

  • Util_ExceptionHandler
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Pry Framework
  4:  *
  5:  * LICENSE
  6:  *
  7:  * This source file is subject to the new BSD license that is bundled
  8:  * with this package in the file LICENSE.txt.
  9:  * 
 10:  * @version $Revision: 276 $
 11:  */
 12: 
 13: /**
 14:  * Gestion des erreurs personnalisée
 15:  * <code>$errorHandler = ErrorHandler::getInstance();</code>
 16:  * 
 17:  * @category Pry
 18:  * @package Util
 19:  * @version 1.0.0 
 20:  * @author Olivier ROGER <oroger.fr>
 21:  */
 22: 
 23: class Util_ErrorHandler
 24: {
 25:     private static $errorHandler;
 26:     private $arrOfMsg = array();
 27:     private $errorContainer = '<div style="padding: .8em; margin-bottom: 1em; border: 2px solid #ff0000;background: #FBE3E4; color: #8a1f11;">
 28:                                 <h3 style="margin-top:5px;">Erreur</h3>';
 29:     private $warnContainer  = '<div style="padding: .8em; margin-bottom: 1em; border: 2px solid #ff9601;background: #fbefe3; color: #d65b09;">
 30:                                 <h3 style="margin-top:5px;">Avertissement</h3>';
 31:     private $noticeContainer = '<div style="padding: .8em; margin-bottom: 1em; border: 2px solid #012bff;background: #e3e9fb; color: #0956d6;">
 32:                                 <h3 style="margin-top:5px;">Avis</h3>';
 33:     /**
 34:      * Constructeur. Appel de la fonction de callback
 35:      * pour la gestion personnalisé des erreurs.
 36:      * 
 37:      * @access private
 38:      */
 39:     private function __construct()
 40:     {
 41:         set_error_handler(array($this,'getError'));
 42:     }
 43:     
 44:     /**
 45:      * Créer l'instance du singleton si elle n'existe pas
 46:      *
 47:      * @return errorHandler
 48:      */
 49:     public static function getInstance() 
 50:     {
 51:         if (!isset(self::$errorHandler)) 
 52:         {
 53:             self::$errorHandler = new self();   
 54:         }
 55:         return self::$errorHandler;
 56:     }
 57:     
 58:     /**
 59:      * Gestion des erreurs "attrapées"
 60:      * @param int $errno Numéro de l'erreur
 61:      * @param string $errstr Message d'erreur
 62:      * @param string $errfile Fichier concerné
 63:      * @param int $errline Numéro de ligne
 64:      *
 65:      */
 66:     public function getError($errno, $errstr, $errfile, $errline)
 67:     {
 68:         $tempMsgError = '';
 69:         switch($errno)
 70:         {
 71:             case E_ERROR:
 72:                 $tempMsgError.=$this->errorContainer;
 73:                 break;
 74:             case E_WARNING:
 75:                 $tempMsgError.=$this->warnContainer;
 76:                 break;
 77:             case E_NOTICE:
 78:                 $tempMsgError.=$this->noticeContainer;
 79:                 break;
 80:             case E_USER_ERROR:
 81:                 $tempMsgError.=$this->errorContainer;
 82:                 break;
 83:             case E_USER_WARNING:
 84:                 $tempMsgError.=$this->warnContainer;
 85:                 break;
 86:             case E_USER_NOTICE:
 87:                 $tempMsgError.=$this->errorContainer;
 88:                 break;
 89:             case E_STRICT:
 90:                 $tempMsgError.=$this->errorContainer;
 91:                 break;
 92:             default:
 93:                 $tempMsgError.=$this->errorContainer;
 94:         }
 95:         $tempMsgError.='<strong>Message :</strong>'.$errstr.'<br /> <strong>Ligne :</strong> '.$errline.'<br /> <strong>Fichier :</strong> '.$errfile.'</div>';
 96:         $this->arrOfMsg[] = $tempMsgError;
 97:     }
 98:     
 99:     public function __destruct()
100:     {
101:         if(count($this->arrOfMsg)>0)
102:         {
103:             foreach($this->arrOfMsg as $msgErreur)
104:             {
105:                 echo $msgErreur;
106:             }
107:         }
108:     }
109: }
110:  ?>
Pry Framework API documentation generated by ApiGen 2.6.1