mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
c8274eca74
This allows differentiating specific and general exceptions in tests; a library-wide trap would have to trap AbstractException
24 lines
No EOL
709 B
PHP
24 lines
No EOL
709 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
namespace JKingWeb\NewsSync\Lang;
|
|
|
|
class Exception extends \JKingWeb\NewsSync\AbstractException {
|
|
static $test = false; // used during PHPUnit testing only
|
|
|
|
function __construct(string $msgID = "", $vars = null, \Throwable $e = null) {
|
|
if(!self::$test) {
|
|
parent::__construct($msgID, $vars, $e);
|
|
} else {
|
|
$codeID = "Lang/Exception.$msgID";
|
|
if(!array_key_exists($codeID,self::CODES)) {
|
|
$code = -1;
|
|
$msg = "Exception.".str_replace("\\","/",parent::class).".uncoded";
|
|
$vars = $msgID;
|
|
} else {
|
|
$code = self::CODES[$codeID];
|
|
$msg = "Exception.".str_replace("\\","/",__CLASS__).".$msgID";
|
|
}
|
|
\Exception::__construct($msg, $code, $e);
|
|
}
|
|
}
|
|
} |