Skip to content

Commit

Permalink
Http error codes for 404 and client Error - 400
Browse files Browse the repository at this point in the history
- `\Leaf\Exception\General::default404();` was providing a custom error page for not found asset but did not return the HTTP error code 404

- \Leaf\Exception\General::csrf(); was not returning any error code when csrf had expired
  • Loading branch information
ibnsultan authored Jan 1, 2024
1 parent 313a113 commit 947b863
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Exception/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,12 @@ public static function defaultDown()
*/
public static function default404()
{
echo static::errorMarkup(
'404',
'<p>The page you are looking for could not be found.</p>'
(new \Leaf\Http\Response())->exit(
static::errorMarkup(
'404',
'<p>The page you are looking for could not be found.</p>'
),
404
);
}

Expand All @@ -211,9 +214,12 @@ public static function default404()
*/
public static function csrf($error = null)
{
echo static::errorMarkup(
'Invalid request',
"<p>$error</p>" ?? '<p>The page you are looking for has expired.</p>'
(new \Leaf\Http\Response())->exit(
static::errorMarkup(
'Invalid request',
"<p>$error</p>" ?? '<p>The page you are looking for has expired.</p>'
),
400
);
}

Expand Down

0 comments on commit 947b863

Please sign in to comment.