Skip to content

Bug: exception message might display in production #6326

@kenjis

Description

@kenjis

This is PoC to show the current PageNotFoundException handling is not good.

.env:

CI_ENVIRONMENT = production
--- a/app/Config/Events.php
+++ b/app/Config/Events.php
@@ -4,6 +4,7 @@ namespace Config;
 
 use CodeIgniter\Events\Events;
 use CodeIgniter\Exceptions\FrameworkException;
+use CodeIgniter\Exceptions\PageNotFoundException;
 
 /*
  * --------------------------------------------------------------------
@@ -46,3 +47,7 @@ Events::on('pre_system', static function () {
         Services::toolbar()->respond();
     }
 });
+
+Events::on('pre_system', static function () {
+    throw new PageNotFoundException('this is raw exception message.');
+});

Navigate to http://localhost:8080/ and you will see:

404 - File Not Found
this is raw exception message.

Metadata

Metadata

Assignees

Labels

bugVerified issues on the current code behavior or pull requests that will fix them

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions