summaryrefslogtreecommitdiff
path: root/src/web/_model/error.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/_model/error.php')
-rw-r--r--src/web/_model/error.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/web/_model/error.php b/src/web/_model/error.php
new file mode 100644
index 0000000..0a08fdd
--- /dev/null
+++ b/src/web/_model/error.php
@@ -0,0 +1,31 @@
+<?php /* Copyright (c) 2024 Freya Murphy */
+class Error_model extends Model {
+
+ function __construct($load) {
+ parent::__construct($load);
+ }
+
+ private function get_msg(&$data) {
+ if (!array_key_exists('code', $_GET)) {
+ http_response_code(500);
+ $data['msg'] = ucfirst(lang('error'));
+ $data['title'] = '500';
+ } else {
+ $code = $_GET['code'];
+ http_response_code($code);
+ $data['title'] = $code;
+ $msg = ucfirst(lang('error_' . $code, FALSE));
+ if (!$msg) {
+ $msg = ucfirst(lang('error'));
+ }
+ $data['msg'] = $msg;
+ }
+ }
+
+ public function get_data(): ?array {
+ $data = parent::get_data();
+ $this->get_msg($data);
+ return $data;
+ }
+}
+?>