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: ResourceException.php 711 2013-07-04 12:05:36Z geert $ 30 */ 31 32 /** 33 * Implementation of the \Scrivo\ResourceException class. 34 */ 35 36 namespace Scrivo; 37 38 /** 39 * Class to represent an error raised due failure of a server resource. 40 * 41 * PHP scripts typically run on a server where the make use of several 42 * server resources, for instance: 43 * 44 * * a database connection 45 * * the file system 46 * * executable commands 47 * 48 * Not to be able to use these resources will generally mean the termination 49 * of the script, as errors in the program logic do. You can use these errors 50 * to discriminate between resource exceptions, program logic exceptions and 51 * application exceptions to take appropriate action: f.i. notify the system 52 * admin, send out bug report or prompt the user for new input. 53 */ 54 class ResourceException extends \Exception { 55 56 /** 57 * Construct a \Scrivo\ResourceException. It is possible to create a 58 * \Scrivo\ResourceException based upon an existing exception: 59 * 60 * .... 61 * } catch (\PdoException $e) { 62 * trhow \Scrivo\ResourceException($e); 63 * } 64 * 65 * or use the standard exception parameters: 66 * 67 * .... 68 * } catch (\PdoException $e) { 69 * trhow \Scrivo\ResourceException("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