Skip to content

Commit dea2feb

Browse files
committed
feat: add a generic error
1 parent e5bf7d5 commit dea2feb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Exception/General.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,26 @@ public static function csrf($error = null)
217217
(new \Leaf\Http\Response())->exit(
218218
static::errorMarkup(
219219
'Invalid request',
220-
"<p>$error</p>" ?? '<p>The page you are looking for has expired.</p>'
220+
$error ? "<p>$error</p>" : '<p>The page you are looking for has expired.</p>'
221221
),
222222
400
223223
);
224224
}
225225

226+
/**
227+
* Generic error page
228+
*/
229+
public static function error($title, $message, $code = 500)
230+
{
231+
(new \Leaf\Http\Response())->exit(
232+
static::errorMarkup(
233+
$title,
234+
"<p>$message</p>"
235+
),
236+
$code
237+
);
238+
}
239+
226240
/**
227241
* Default Error handler
228242
*/

0 commit comments

Comments
 (0)