* @copyright 2023 - 2025 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License * * @note This program is distributed in the hope that it will be useful * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. * * @category Framework * @filesource * * @link https://catalyst.dock Local development URL * * Error Test component for the Catalyst Framework * */ use Catalyst\Helpers\Error\BugCatcher; /** * Test function to run various error scenarios * * @param string $testType Type of test to run (error, exception, fatal) * @return void * @throws Exception */ function runErrorTest(string $testType = 'all'): void { echo "

Catalyst Error Handling System Test

"; echo "

Testing error type: " . htmlspecialchars($testType) . "

"; // Initialize the error handling system BugCatcher::getInstance()->initialize(); switch ($testType) { case 'error': // Test a PHP warning echo "

Testing PHP Warning...

"; trigger_error("This is a forced error", E_USER_ERROR); break; case 'notice': // Test a PHP notice echo "

Testing PHP Notice...

"; $array = []; echo $array['non_existent_key']; break; case 'exception': // Test an exception echo "

Testing Exception...

"; throw new Exception("This is a test exception"); break; case 'fatal': // Test a fatal error echo "

Testing Fatal Error...

"; non_existent_function(); break; case 'all': default: // Let user choose which test to run echo <<Choose a test to run:

HTML; break; } }