mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-22 08:05:34 +08:00
refactor ZMException
This commit is contained in:
@@ -6,22 +6,17 @@ namespace ZM\Exception;
|
||||
|
||||
class ConfigException extends ZMException
|
||||
{
|
||||
public const UNSUPPORTED_FILE_TYPE = 'E00079';
|
||||
public const UNSUPPORTED_FILE_TYPE = 79;
|
||||
|
||||
public const LOAD_CONFIG_FAILED = 'E00080';
|
||||
|
||||
public function __construct($err_code, $message = '', $code = 0, \Throwable $previous = null)
|
||||
{
|
||||
parent::__construct(zm_internal_errcode($err_code) . $message, $code, $previous);
|
||||
}
|
||||
public const LOAD_CONFIG_FAILED = 80;
|
||||
|
||||
public static function unsupportedFileType(string $file_path): ConfigException
|
||||
{
|
||||
return new self(self::UNSUPPORTED_FILE_TYPE, "不支持的配置文件类型:{$file_path}");
|
||||
return new self("不支持的配置文件类型:{$file_path}", "请检查配置文件的后缀名是否正确", self::UNSUPPORTED_FILE_TYPE);
|
||||
}
|
||||
|
||||
public static function loadConfigFailed(string $file_path, string $message): ConfigException
|
||||
{
|
||||
return new self(self::LOAD_CONFIG_FAILED, "加载配置文件失败:{$file_path},{$message}");
|
||||
return new self("加载配置文件失败:{$file_path},{$message}", "请检查配置文件的格式是否正确,并尝试按照错误信息排查", self::LOAD_CONFIG_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user