PHP Classes
Icontem

File: gCurl/gksException.class.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Grigori Kochanov  >  gCurl  >  gCurl/gksException.class.php  
File: gCurl/gksException.class.php
Role: Class source
Content type: text/plain
Description: interface for all my exception classes
Class: gCurl
Perform HTTP requests using Curl
 

Contents

Class file image Download
<?php
/**
 * The interface defines the methods that prepare the log message, HTML-formatted message
 *
 */
interface gksException{
    
/**
     * Prepare the message to write to the log
     *
     * @return  string
     */
    
public function getLogMessage();
    
    
/**
     * returns the exception dump prepared for a browser
     * 
     * @return string
     */
    
public function getHtmlMessage();
}

/*    EXCEPTIONS   */
class pException extends Exception implements gksException {

static 
private $error_codes;
public $httpResponceCode=500;
public $defaultErrorMessage;

/**
 * @param $code int - error code from [lang].errors.php
 * @desc returns the value of the configuration parameter (from the database)
 */
function __construct($code){
    if (!
self::$error_codes){
        
$errors_file=_Config::$CONFIG_DIR.'/errors.php';
        
self::$error_codes = include($errors_file);
    }
    
$this->defaultErrorMessage=self::$error_codes[1];

    
key_exists($codeself::$error_codes) || $code=1;
    
$message=self::$error_codes[$code];
    
parent::__construct($message$code);
}

/**
 * Create the message to write to the log
 *
 * @return  string
 */
function getLogMessage(){
    
$log_string='Exception: '.$this->getMessage().' ('.$this->getCode().')'."\n".
        
'line '.$this->getLine().' file '.$this->getFile()."\n".$this->getTraceAsString()."\n";
    return 
$log_string;
}

public function getHtmlMessage(){
    
$message 'Exception: 'nl2br ($this->getMessage());
    
$trace 'TRACE: <br />'nl2br ($this->getTraceAsString());
    return 
'<p style="font-weignt: bold; padding: 10px;">'."\n".$message."<br />\n".$trace."</p>\n";
}
//class end
}

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products