1 <?php 2 3 4 namespace ComboStrap; 5 6 7 use Throwable; 8 9 /** 10 * Class ExceptionCombo 11 * @package ComboStrap 12 * Adds the canonical 13 * 14 * An error that is in the code 15 */ 16 class ExceptionRuntime extends \RuntimeException 17 { 18 /** 19 * @var mixed|string 20 */ 21 private $canonical; 22 23 public function __construct($message = "", $canonical = "", $code = 0, Throwable $previous = null) 24 { 25 $this->canonical = $canonical; 26 parent::__construct($message, $code, $previous); 27 } 28 29 30 public static function withError(Throwable $previous) 31 { 32 $calledClass = get_called_class(); 33 return new $calledClass($previous->getMessage(), "support", 1, $previous); 34 } 35 36 public static function withMessageAndError(string $message, Throwable $previous) 37 { 38 $calledClass = get_called_class(); 39 return new $calledClass($message, "support", 1, $previous); 40 } 41 42 /** 43 * @return mixed|string 44 */ 45 public function getCanonical() 46 { 47 return $this->canonical; 48 } 49 50 51 } 52