summaryrefslogtreecommitdiff
path: root/classes/errors.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2023-10-25 12:55:09 +0300
committerAndrew Dolgov <[email protected]>2023-10-25 12:55:09 +0300
commit865ecc87963dc3b26e66296616eef2a1cc41ac3f (patch)
treebf2ecd8a391103bdb2c8b70cd33c47467310754b /classes/errors.php
parent0a5507d3bd79d04c860455664f919bf8e7274fda (diff)
move to psr-4 autoloader
Diffstat (limited to 'classes/errors.php')
-rw-r--r--classes/errors.php40
1 files changed, 0 insertions, 40 deletions
diff --git a/classes/errors.php b/classes/errors.php
deleted file mode 100644
index aa626d017..000000000
--- a/classes/errors.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-class Errors {
- const E_SUCCESS = "E_SUCCESS";
- const E_UNAUTHORIZED = "E_UNAUTHORIZED";
- const E_UNKNOWN_METHOD = "E_UNKNOWN_METHOD";
- const E_UNKNOWN_PLUGIN = "E_UNKNOWN_PLUGIN";
- const E_SCHEMA_MISMATCH = "E_SCHEMA_MISMATCH";
- const E_URL_SCHEME_MISMATCH = "E_URL_SCHEME_MISMATCH";
-
- /**
- * @param Errors::E_* $code
- * @param array<string, string> $params
- */
- static function to_json(string $code, array $params = []): string {
- return json_encode(["error" => ["code" => $code, "params" => $params]]);
- }
-
- static function libxml_last_error() : string {
- $error = libxml_get_last_error();
- $error_formatted = "";
-
- if ($error) {
- foreach (libxml_get_errors() as $error) {
- if ($error->level == LIBXML_ERR_FATAL) {
- // currently only the first error is reported
- $error_formatted = self::format_libxml_error($error);
- break;
- }
- }
- }
-
- return UConverter::transcode($error_formatted, 'UTF-8', 'UTF-8');
- }
-
- static function format_libxml_error(LibXMLError $error) : string {
- return sprintf("LibXML error %s at line %d (column %d): %s",
- $error->code, $error->line, $error->column,
- $error->message);
- }
-}