<?php
/**
 * File: ResponseException.php
 * Enconding: UTF-8
 * Using:
 */
namespace app\modules\sys\exception;

use yii\base\UserException;

class ResponseException extends UserException
{
    private $intCode;
    private $strMsg;

    public function __construct($intCode, $strMsg)
    {
        $this->intCode = $intCode;
        $this->strMsg  = $strMsg;
        parent::__construct($strMsg, $intCode);
    }

    public function getName()
    {
        return $this->__toString();
    }

    /**
     * 输出
     */
    public function __toString()
    {
        $arrData = [
            'code' => "{$this->intCode}",
            'msg'  => $this->strMsg
        ];

        return json_encode($arrData);
    }
}
