1*cbeaa4a0SAndreas Gohr<?php 2*cbeaa4a0SAndreas Gohr 3*cbeaa4a0SAndreas Gohrnamespace splitbrain\phpcli; 4*cbeaa4a0SAndreas Gohr 5*cbeaa4a0SAndreas Gohr/** 6*cbeaa4a0SAndreas Gohr * Class Exception 7*cbeaa4a0SAndreas Gohr * 8*cbeaa4a0SAndreas Gohr * The code is used as exit code for the CLI tool. This should probably be extended. Many cases just fall back to the 9*cbeaa4a0SAndreas Gohr * E_ANY code. 10*cbeaa4a0SAndreas Gohr * 11*cbeaa4a0SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 12*cbeaa4a0SAndreas Gohr * @license MIT 13*cbeaa4a0SAndreas Gohr */ 14*cbeaa4a0SAndreas Gohrclass Exception extends \Exception 15*cbeaa4a0SAndreas Gohr{ 16*cbeaa4a0SAndreas Gohr const E_ANY = -1; // no error code specified 17*cbeaa4a0SAndreas Gohr const E_UNKNOWN_OPT = 1; //Unrecognized option 18*cbeaa4a0SAndreas Gohr const E_OPT_ARG_REQUIRED = 2; //Option requires argument 19*cbeaa4a0SAndreas Gohr const E_OPT_ARG_DENIED = 3; //Option not allowed argument 20*cbeaa4a0SAndreas Gohr const E_OPT_ABIGUOUS = 4; //Option abiguous 21*cbeaa4a0SAndreas Gohr const E_ARG_READ = 5; //Could not read argv 22*cbeaa4a0SAndreas Gohr 23*cbeaa4a0SAndreas Gohr /** 24*cbeaa4a0SAndreas Gohr * @param string $message The Exception message to throw. 25*cbeaa4a0SAndreas Gohr * @param int $code The Exception code 26*cbeaa4a0SAndreas Gohr * @param \Exception $previous The previous exception used for the exception chaining. 27*cbeaa4a0SAndreas Gohr */ 28*cbeaa4a0SAndreas Gohr public function __construct($message = "", $code = 0, \Exception $previous = null) 29*cbeaa4a0SAndreas Gohr { 30*cbeaa4a0SAndreas Gohr if (!$code) { 31*cbeaa4a0SAndreas Gohr $code = self::E_ANY; 32*cbeaa4a0SAndreas Gohr } 33*cbeaa4a0SAndreas Gohr parent::__construct($message, $code, $previous); 34*cbeaa4a0SAndreas Gohr } 35*cbeaa4a0SAndreas Gohr} 36