Changeset 1089

Show
Ignore:
Timestamp:
11/29/07 19:12:31 (9 months ago)
Author:
mikey
Message:

refactored exception handler (side effect of enhancement #112)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/examples/docroot/core/exception.php

    r744 r1089  
    11<?php 
    22require '../bootstrap-stubbles.php'; 
    3 stubClassLoader::load('net.stubbles.util.stubExceptionHandler', 
     3stubClassLoader::load('net.stubbles.util.errorhandler.stubProdModeExceptionHandler', 
     4                      'net.stubbles.util.errorhandler.stubDisplayExceptionHandler', 
    45                      'net.stubbles.util.stubRegistry' 
    56); 
     
    89    public static function main() 
    910    { 
    10         if (isset($_GET['test']) == true) { 
    11             stubRegistry::setConfig('net.stubbles.mode', 'test'); 
     11        if (isset($_GET['test']) === true) { 
     12            $exceptionHandler = new stubDisplayExceptionHandler(); 
    1213            echo '<pre>'; 
     14        } else { 
     15            $exceptionHandler = new stubProdModeExceptionHandler(); 
    1316        } 
    1417         
    15         stubExceptionHandler::register(); 
     18        $exceptionHandler->setLogging(false); 
     19        set_exception_handler(array($exceptionHandler, 'handleException')); 
    1620        throw new stubException('This is an exception'); 
    1721        echo 'This will never be displayed.'; 
  • trunk/src/main/php/net/stubbles/lang/stubMode.php

    r1050 r1089  
    1515 * or not. Currently, there are four different modes available: 
    1616 * stubMode::$PROD 
    17  *      - uses default exception handler net.stubbles.util.stubExceptionHandler 
     17 *      - uses exception handler net::stubbles::util::errorhandler::stubProdModeExceptionHandler 
    1818 *      - uses default error handler net.stubbles.util.errorhandler.stubDefaultErrorHandler 
    1919 *      - caching enabled 
    2020 * stubMode::$TEST 
    21  *      - no exception handler and no error handler 
     21 *      - uses exception handler net::stubbles::util::errorhandler::stubDisplayExceptionHandler 
     22 *      - no error handler 
    2223 *      - caching enabled 
    2324 * stubMode::$STAGE 
    24  *      - no exception handler and no error handler 
     25 *      - uses exception handler net::stubbles::util::errorhandler::stubDisplayExceptionHandler 
     26 *      - no error handler 
    2527 *      - caching disabled 
    2628 * stubMode::$DEV 
    27  *      - no exception handler and no error handler 
     29 *      - uses exception handler net::stubbles::util::errorhandler::stubDisplayExceptionHandler 
     30 *      - no error handler 
    2831 *      - caching disabled 
    2932 * While stage and dev mode currently are not different this may change in 
     
    9194    public static function __static() 
    9295    { 
    93         self::$PROD                    = new self('PROD', 0); 
    94         self::$PROD->exceptionHandler  = array('class'  => 'net.stubbles.util.stubExceptionHandler', 
    95                                                'method' => 'handle' 
    96                                          ); 
    97         self::$PROD->errorHandler      = array('class'  => 'net.stubbles.util.errorhandler.stubDefaultErrorHandler', 
    98                                                'method' => 'handle' 
    99                                          ); 
    100         self::$TEST                    = new self('TEST', 1); 
    101         self::$STAGE                   = new self('STAGE', 2); 
    102         self::$STAGE->enableCache      = false; 
    103         self::$DEV                     = new self('STAGE', 3); 
    104         self::$DEV->enableCache        = false; 
     96        self::$PROD                     = new self('PROD', 0); 
     97        self::$PROD->exceptionHandler   = array('class'  => 'net.stubbles.util.errorhandler.stubProdModeExceptionHandler', 
     98                                                'method' => 'handle' 
     99                                          ); 
     100        self::$PROD->errorHandler       = array('class'  => 'net.stubbles.util.errorhandler.stubDefaultErrorHandler', 
     101                                                'method' => 'handle' 
     102                                          ); 
     103        self::$TEST                     = new self('TEST', 1); 
     104        self::$TEST->exceptionHandler   = array('class'  => 'net.stubbles.util.errorhandler.stubDisplayExceptionHandler', 
     105                                                'method' => 'handle' 
     106                                          ); 
     107        self::$STAGE                    = new self('STAGE', 2); 
     108        self::$STAGE->exceptionHandler  = array('class'  => 'net.stubbles.util.errorhandler.stubDisplayExceptionHandler', 
     109                                                'method' => 'handle' 
     110                                          ); 
     111        self::$STAGE->enableCache       = false; 
     112        self::$DEV                      = new self('STAGE', 3); 
     113        self::$DEV->exceptionHandler    = array('class'  => 'net.stubbles.util.errorhandler.stubDisplayExceptionHandler', 
     114                                                'method' => 'handle' 
     115                                          ); 
     116        self::$DEV->enableCache         = false; 
    105117    } 
    106118