2016-09-30 01:58:09 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace JKingWeb\NewsSync;
|
|
|
|
|
|
|
|
class Exception extends \Exception {
|
|
|
|
|
|
|
|
const CODES = [
|
2017-02-06 00:00:57 +00:00
|
|
|
"Exception.uncoded" => -1,
|
2017-02-11 18:50:34 +00:00
|
|
|
"Exception.invalid" => 1, // this exception MUST NOT have a message string defined
|
2017-02-09 21:56:30 +00:00
|
|
|
"Exception.unknown" => 10000,
|
2016-09-30 01:58:09 +00:00
|
|
|
"Lang/Exception.defaultFileMissing" => 10101,
|
|
|
|
"Lang/Exception.fileMissing" => 10102,
|
|
|
|
"Lang/Exception.fileUnreadable" => 10103,
|
|
|
|
"Lang/Exception.fileCorrupt" => 10104,
|
|
|
|
"Lang/Exception.stringMissing" => 10105,
|
2016-10-06 02:20:45 +00:00
|
|
|
"Db/Exception.extMissing" => 10201,
|
|
|
|
"Db/Exception.fileMissing" => 10202,
|
|
|
|
"Db/Exception.fileUnusable" => 10203,
|
|
|
|
"Db/Exception.fileUnreadable" => 10204,
|
|
|
|
"Db/Exception.fileUnwritable" => 10205,
|
|
|
|
"Db/Exception.fileUncreatable" => 10206,
|
|
|
|
"Db/Exception.fileCorrupt" => 10207,
|
2016-10-28 12:27:35 +00:00
|
|
|
"Db/Update/Exception.tooNew" => 10211,
|
|
|
|
"Db/Update/Exception.fileMissing" => 10212,
|
|
|
|
"Db/Update/Exception.fileUnusable" => 10213,
|
|
|
|
"Db/Update/Exception.fileUnreadable" => 10214,
|
|
|
|
"Db/Update/Exception.manual" => 10215,
|
|
|
|
"Db/Update/Exception.manualOnly" => 10216,
|
|
|
|
"Conf/Exception.fileMissing" => 10302,
|
|
|
|
"Conf/Exception.fileUnusable" => 10303,
|
|
|
|
"Conf/Exception.fileUnreadable" => 10304,
|
|
|
|
"Conf/Exception.fileUnwritable" => 10305,
|
|
|
|
"Conf/Exception.fileUncreatable" => 10306,
|
|
|
|
"Conf/Exception.fileCorrupt" => 10307,
|
|
|
|
"User/Exception.functionNotImplemented" => 10401,
|
|
|
|
"User/Exception.doesNotExist" => 10402,
|
|
|
|
"User/Exception.alreadyExists" => 10403,
|
|
|
|
"User/Exception.authMissing" => 10411,
|
|
|
|
"User/Exception.authFailed" => 10412,
|
2016-11-04 02:54:27 +00:00
|
|
|
"User/Exception.notAuthorized" => 10421,
|
2016-09-30 01:58:09 +00:00
|
|
|
];
|
|
|
|
|
2016-10-06 02:08:43 +00:00
|
|
|
public function __construct(string $msgID = "", $vars = null, \Throwable $e = null) {
|
2016-09-30 01:58:09 +00:00
|
|
|
if($msgID=="") {
|
2017-02-10 04:05:13 +00:00
|
|
|
$msg = "Exception.unknown";
|
|
|
|
$code = 10000;
|
2016-09-30 01:58:09 +00:00
|
|
|
} else {
|
2017-02-06 00:00:57 +00:00
|
|
|
$codeID = str_replace("\\", "/", str_replace(NS_BASE, "", get_called_class())).".$msgID";
|
2016-09-30 01:58:09 +00:00
|
|
|
if(!array_key_exists($codeID,self::CODES)) {
|
2017-02-11 18:50:34 +00:00
|
|
|
throw new self("uncoded");
|
2016-09-30 01:58:09 +00:00
|
|
|
} else {
|
|
|
|
$code = self::CODES[$codeID];
|
2017-02-06 00:00:57 +00:00
|
|
|
$msg = "Exception.".str_replace("\\","/",get_called_class()).".$msgID";
|
2016-09-30 01:58:09 +00:00
|
|
|
}
|
2017-02-06 00:00:57 +00:00
|
|
|
$msg = Lang::msg($msg, $vars);
|
2016-09-30 01:58:09 +00:00
|
|
|
}
|
|
|
|
parent::__construct($msg, $code, $e);
|
|
|
|
}
|
|
|
|
}
|