Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the error view is determined by Exception code #8689

Merged

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Mar 31, 2024

Description
It should be determined by the HTTP status code.
Otherwise, if by chance an exception with code 404 is thrown, a 404 Not Found page will be displayed.

<?php

namespace App\Controllers;

use Exception;

class Home extends BaseController
{
    public function index(): string
    {
        throw new Exception('This is an exception message', 404);
    }
}

Before:
404 - Page Not Found

404
This is an exception message

HTTP Status: 500

After:
Exception

Exception #404
This is an exception message 

HTTP Status: 500

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

It should be determined by HTTP status code.
Otherwise, if by chance an exception with code 404 is thrown,
a 404 Not Found page will be displayed.
@kenjis kenjis added bug Verified issues on the current code behavior or pull requests that will fix them breaking change Pull requests that may break existing functionalities labels Mar 31, 2024
@kenjis kenjis marked this pull request as draft March 31, 2024 02:16
@kenjis kenjis changed the title fix: bug that the error view is determined by Exception code fix: the error view is determined by Exception code Mar 31, 2024
@kenjis kenjis mentioned this pull request Mar 31, 2024
3 tasks
@kenjis kenjis added the docs needed Pull requests needing documentation write-ups and/or revisions. label Mar 31, 2024
@kenjis kenjis removed breaking change Pull requests that may break existing functionalities docs needed Pull requests needing documentation write-ups and/or revisions. labels Mar 31, 2024
@kenjis kenjis marked this pull request as ready for review March 31, 2024 04:44
@kenjis kenjis merged commit 22db69c into codeigniter4:develop Apr 2, 2024
57 checks passed
@kenjis kenjis deleted the fix-ExceptionHandler-determineView branch April 2, 2024 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants