2021-02-23 19:31:43 +00:00
|
|
|
<?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";
|
2021-02-26 11:14:44 +00:00
|
|
|
const E_URL_SCHEME_MISMATCH = "E_URL_SCHEME_MISMATCH";
|
2021-02-23 19:31:43 +00:00
|
|
|
|
2021-11-10 21:38:25 +00:00
|
|
|
/**
|
|
|
|
* @param Errors::E_* $code
|
|
|
|
* @param array<string, string> $params
|
|
|
|
*/
|
|
|
|
static function to_json(string $code, array $params = []): string {
|
2021-02-26 11:14:44 +00:00
|
|
|
return json_encode(["error" => ["code" => $code, "params" => $params]]);
|
2021-02-23 19:31:43 +00:00
|
|
|
}
|
|
|
|
}
|