Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(phpversion() < 5.3){
- class baseException extends Exception{
- /**
- * @var Exception
- */
- protected $previousException;
- /**
- * @param string $message
- * @param int $code
- * @param Exception $previous
- */
- function __construct($message = '', $code = 0, $previous = null) {
- parent::__construct($message, 0);
- $this->previousException = $previous;
- }
- /**
- * @return Exception
- */
- public function getPrevious() {
- return $this->previousException;
- }
- /**
- * @return string
- */
- public function _getTraceAsString() {
- if($this->previousException === null){
- return parent::getTraceAsString();
- }
- if($this->previousException instanceof BaseException){
- return $this->previousException->_getTraceAsString();
- }
- return $this->previousException->getTraceAsString();
- }
- /**
- * @return array
- */
- public function _getTrace() {
- if($this->previousException === null){
- return parent::getTrace();
- }
- if($this->previousException instanceof BaseException){
- return $this->previousException->_getTrace();
- }
- return $this->previousException->getTrace();
- }
- /**
- * @return string
- */
- public function __toString() {
- return "exception '".__CLASS__ ."' with message '".$this->getMessage()
- ."' in ".$this->getFile().":".$this->getLine()
- ."\nStack trace:\n".$this->_getTraceAsString();
- }
- }
- } else {
- class baseException extends Exception{
- public function __construct($message, $code = 0, $previous = null) {
- parent::__construct($message, 0, $previous);
- }
- /**
- * @return string
- */
- public function _getTraceAsString() {
- return $this->getTraceAsString();
- }
- /**
- * @return array
- */
- public function _getTrace() {
- return $this->getTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement