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