Error handler and allow video IDs from app share

This commit is contained in:
Pablo Ferreiro 2022-01-11 19:25:30 +01:00
parent f18dd802d5
commit 93de0c2d23
No known key found for this signature in database
GPG key ID: 41FBCE65B779FA24
9 changed files with 107 additions and 20 deletions

25
helpers/Error.php Normal file
View file

@ -0,0 +1,25 @@
<?php
namespace Helpers;
class Error {
const list = [
'api' => [
'code' => 500,
'message' => 'API unknown error, please check back later'
],
'latte' => [
'code' => 500,
'message' => 'Template render crash, please check back later'
]
];
static public function show(string $type) {
$keys = array_keys(self::list);
if (in_array($type, $keys)) {
$error = self::list[$type];
http_response_code($error['code']);
$latte = Misc::latte();
$latte->render(Misc::getView('error'), ['type' => $type, 'error' => $error]);
}
}
}