aboutsummaryrefslogtreecommitdiff
path: root/skin/error.skin.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-07-09 19:40:17 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-07-09 19:40:17 +0300
commitf7bfdf58def6aadc922e1632f407d1418269a0d7 (patch)
treed7a0b2819e6a26c11d40ee0b27267ea827fbb345 /skin/error.skin.php
initial
Diffstat (limited to 'skin/error.skin.php')
-rw-r--r--skin/error.skin.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/skin/error.skin.php b/skin/error.skin.php
new file mode 100644
index 0000000..b0925d3
--- /dev/null
+++ b/skin/error.skin.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace skin\error;
+
+use Stringable;
+
+function forbidden($ctx, $message) {
+ return $ctx->common(403, 'Forbidden', $message);
+}
+
+function not_found($ctx, $message) {
+ return $ctx->common(404, 'Not Found', $message);
+}
+
+function unauthorized($ctx, $message) {
+ return $ctx->common(401, 'Unauthorized', $message);
+}
+
+function not_implemented($ctx, $message) {
+ return $ctx->common(501, 'Not Implemented', $message);
+}
+
+function common($ctx,
+ int $code,
+ string|Stringable $title,
+ string|Stringable|null $message = null) {
+return <<<HTML
+<html>
+ <head><title>$code $title</title></head>
+ <body>
+ <center><h1>$code $title</h1></center>
+ {$ctx->if_true($message,
+ '<hr><p align="center">'.$message.'</p>'
+ )}
+
+ </body>
+</html>
+HTML;
+
+} \ No newline at end of file