Changeset 389
- Timestamp:
- 03/16/07 14:32:50 (1 year ago)
- Files:
-
- trunk/build/stubbles/build.xml (modified) (1 diff)
- trunk/config/errors (added)
- trunk/config/errors/500.html (added)
- trunk/src/main/php/net/stubbles/util/stubExceptionHandler.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/stubbles/build.xml
r329 r389 33 33 <mkdir dir="${build.src.dir}/cache" /> 34 34 <mkdir dir="${build.src.dir}/cache/xml" /> 35 36 <mkdir dir="${build.src.dir}/config/errors" /> 37 <copy file="${project.basedir}/../../config/errors/500.html" tofile="${build.src.dir}/config/errors/500-dist.html" /> 35 38 36 39 <mkdir dir="${build.src.dir}/config/php" /> trunk/src/main/php/net/stubbles/util/stubExceptionHandler.php
r360 r389 16 16 * @package stubbles 17 17 * @subpackage util 18 * @Inject(stubRequest:stubResponse) 18 19 */ 19 20 class stubExceptionHandler extends stubBaseObject implements stubPreInterceptor 20 21 { 22 /** 23 * access to request instance 24 * 25 * @var stubRequest 26 */ 27 protected static $request; 28 /** 29 * access to response instance 30 * 31 * @var stubResponse 32 */ 33 protected static $response; 34 21 35 /** 22 36 * registers the exception handler … … 34 48 public static function handle(Exception $exception) 35 49 { 50 if (null != self::$request) { 51 self::$request->cancel(); 52 } 53 54 if (null == self::$response) { 55 self::$response = new stubBaseResponse(); 56 } 57 36 58 if (stubRegistry::hasConfig('net.stubbles.mode') == true && stubRegistry::getConfig('net.stubbles.mode') == 'test') { 37 $response = new stubBaseResponse();38 59 if ($exception instanceof stubException) { 39 $response->write($exception);60 self::$response->replaceData((string) $exception); 40 61 } else { 41 $response->write($exception->getMessage());62 self::$response->replaceData($exception->getMessage()); 42 63 } 43 $response->send();44 64 } else { 45 65 header('HTTP/1.0 500 Internal Server Error'); 66 self::$response->replaceData(file_get_contents(stubConfig::getConfigPath() . '/errors/500.html')); 46 67 } 68 69 // send the response because the request will end right after this 70 // method has been finished 71 self::$response->send(); 72 } 73 74 /** 75 * sets the request instance 76 * 77 * @param stubRequest $request 78 */ 79 public function setRequest(stubRequest $request) 80 { 81 self::$request = $request; 82 } 83 84 /** 85 * sets the response instance 86 * 87 * @param stubResponse $response 88 */ 89 public function setResponse(stubResponse $response) 90 { 91 self::$response = $response; 47 92 } 48 93
