1 <?php 2 /* Copyright (c) 2012, Geert Bergman (geert@scrivo.nl) 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * 3. Neither the name of "Scrivo" nor the names of its contributors may be 14 * used to endorse or promote products derived from this software without 15 * specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * POSSIBILITY OF SUCH DAMAGE. 28 * 29 * $Id: SystemException.php 711 2013-07-04 12:05:36Z geert $ 30 */ 31 32 /** 33 * Implementation of the \Scrivo\SystemException class. 34 */ 35 36 namespace Scrivo; 37 38 /** 39 * Class to represent an error raised due failure in Scrivo program logic. 40 * 41 * This class is for runtime errors of a technical nature that should normaly 42 * not occur in script execution, with script termination as most the likely 43 * course of action. For instance: 44 * 45 * * Division by zero where there was no user input. 46 * * Illegal argument types. 47 * * Index out of bounds. 48 * 49 * You can use these errors to discriminate between resource exceptions, 50 * system exceptions and application exceptions to take appropriate 51 * action: f.i. notify the system admin, send out bug report or prompt the 52 * user for new input. 53 */ 54 class SystemException extends \Exception { 55 56 /** 57 * Construct a \Scrivo\SystemException. It is possible to create a 58 * \Scrivo\SystemException based upon an existing exception: 59 * 60 * .... 61 * } catch (\InvalidArgumentException $e) { 62 * trhow \Scrivo\SystemException($e); 63 * } 64 * 65 * or use the standard exception parameters: 66 * 67 * .... 68 * } catch (\InvalidArgumentException $e) { 69 * trhow \Scrivo\SystemException("Message", 123, $e); 70 * } 71 * 72 * @param \Exception|string $messageOrException The error message or 73 * original exception. 74 * @param int $code Optional exception code if the first parameter was 75 * an error string, else not applicable. 76 * @param \Exception $previous Optional, the original exception if the 77 * first parameter was an error string, else not applicable. 78 */ 79 public function __construct($messageOrException = null , $code = null, 80 \Exception $previous = null) { 81 if ($messageOrException instanceof \Exception) { 82 parent::__construct($messageOrException->message, 83 0, $messageOrException); 84 $this->code = $messageOrException->code; 85 $this->file = $messageOrException->file; 86 $this->line = $messageOrException->line; 87 } else { 88 parent::__construct($messageOrException, $code, $previous); 89 } 90 } 91 92 } 93 94 ?>
Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013