12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace components;
- use Yii;
- use yii\base\UserException;
- /**
- * 异常 模型
- * Class Exception
- * @package components
- */
- class Exception extends UserException
- {
- const ERROR = 'AMQ ERROR';
- const UNKNOWN_ERROR_CODE = 500;
- /**
- * Exception constructor.
- * @param null $code
- * @param null $message
- * @param null $previous
- */
- public function __construct($code = null, $message = null, $previous = null)
- {
- if (is_numeric($message) && is_string($code)) {
- list($code, $message) = [$message, $code];
- }
- $code = is_numeric($code) ? $code : self::UNKNOWN_ERROR_CODE;
- $message = $message ?: Yii::t('error', $code);
- parent::__construct($message, $code, $previous);
- }
- /**
- * 获取异常信息
- * @return string
- */
- public function getName()
- {
- return self::ERROR;
- }
- }
|