You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
824 B
PHTML
36 lines
824 B
PHTML
1 year ago
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
/**
|
||
|
* This file is part of Hyperf.
|
||
|
*
|
||
|
* @link https://www.hyperf.io
|
||
|
* @document https://hyperf.wiki
|
||
|
* @contact group@hyperf.io
|
||
|
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||
|
*/
|
||
|
namespace App\Exception;
|
||
|
|
||
|
use App\Constants\ResultCode;
|
||
|
use Throwable;
|
||
|
|
||
|
class ApiException extends BasicException
|
||
|
{
|
||
|
protected $code = ResultCode::DEFAULT_ERROR;
|
||
|
|
||
|
protected $errorCode;
|
||
|
|
||
|
public function __construct(string $message = null, string $errorCode = null, Throwable $previous = null)
|
||
|
{
|
||
|
if (is_null($message)) {
|
||
|
$message = ResultCode::getMessage($this->code);
|
||
|
}
|
||
|
$this->errorCode = $errorCode;
|
||
|
parent::__construct($message, $previous);
|
||
|
}
|
||
|
|
||
|
public function getErrorCode() {
|
||
|
return $this->errorCode;
|
||
|
}
|
||
|
}
|