<?php

	// namespace
	namespace sven\sys;


	/**
	 * Exception
	 *
	 * Custom Exception Handler
	 *
	 * @package sven\sys
	 * @copyright 2018 Ruben Meyer
	 * @author Ruben Meyer <contact@rxbn.de>
	 * @version 0.1.0
	 * @see http://php.net/manual/en/class.exception.php	<Documentation>
	 * @TODO Comments
	 */
	class Exception extends \Exception {

		private $title;

		public function __construct($title, $message = null, $code = 0, \Exception $previous = null) {
			\sven\sys\core::addReplacement("head", "TITLE", "Exception", true);
			if(func_get_args()[0] instanceof \Exception) {
				$e = func_get_args()[0];
				$this->title = get_class($e);

				$code = (gettype($e->getCode()) === "integer") ? $e->getCode() : $code;

	        	parent::__construct($e->getMessage(), $code, $e);
			} else {
				$this->title = $title;
	        	parent::__construct($message, $code, $previous);
			}
		}

		public function getTitle() {
			return $this->title;
		}

	};

?>
