parent
410aa4a92c
commit
b1d25b4941
28
MDErrorCategory.php
Normal file
28
MDErrorCategory.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?PHP
|
||||
/**
|
||||
* Represents an error category.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents an error category.
|
||||
*/
|
||||
enum MDErrorCategory implements JsonSerializable {
|
||||
|
||||
case unknown;
|
||||
case critical;
|
||||
case known;
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
|
@ -9,13 +9,7 @@ declare(strict_types = 1);
|
|||
*/
|
||||
final class MDErrorReporter {
|
||||
|
||||
const MD_ERROR_UNKNOWN = 20;
|
||||
const MD_ERROR_CRITICAL = 10;
|
||||
const MD_ERROR_KNOWN = 0;
|
||||
|
||||
/** @var string */
|
||||
private string $_context;
|
||||
/** @var string */
|
||||
private string $_contact_mail_addr;
|
||||
|
||||
/**
|
||||
|
@ -23,9 +17,9 @@ final class MDErrorReporter {
|
|||
*
|
||||
* @param Throwable $exception Exception to be categorized.
|
||||
*
|
||||
* @return integer
|
||||
* @return MDErrorCategory
|
||||
*/
|
||||
public static function categorizeError(Throwable $exception):int {
|
||||
public static function categorizeError(Throwable $exception):MDErrorCategory {
|
||||
|
||||
if ($exception instanceof MDpageParameterMissingException
|
||||
|| $exception instanceof MDpageParameterNotNumericException
|
||||
|
@ -44,10 +38,10 @@ final class MDErrorReporter {
|
|||
|| $exception instanceof MDcouldNotSetPublic
|
||||
|| $exception instanceof MDInvalidNodaLink
|
||||
) {
|
||||
return self::MD_ERROR_KNOWN;
|
||||
return MDErrorCategory::known;
|
||||
}
|
||||
|
||||
return self::MD_ERROR_UNKNOWN;
|
||||
return MDErrorCategory::unknown;
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user