4 * This file is part of Psy Shell.
6 * (c) 2012-2017 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Psy\Exception;
15 * A "type error" Exception for Psy.
17 class TypeErrorException extends \Exception implements Exception
24 * @param string $message (default: "")
25 * @param int $code (default: 0)
27 public function __construct($message = '', $code = 0)
29 $this->rawMessage = $message;
30 $message = preg_replace('/, called in .*?: eval\\(\\)\'d code/', '', $message);
31 parent::__construct(sprintf('TypeError: %s', $message), $code);
35 * Get the raw (unformatted) message for this error.
39 public function getRawMessage()
41 return $this->rawMessage;
45 * Create a TypeErrorException from a TypeError.
47 * @param \TypeError $e
49 * @return TypeErrorException
51 public static function fromTypeError(\TypeError $e)
53 return new self($e->getMessage(), $e->getLine());