3

Is there a way to turn off the fancy error reporting in Codeigniter 4? I prefer the classic way.

Dusan
  • 3,284
  • 6
  • 25
  • 46
  • What do you mean by "The classic way"? What's the problem you're facing with the error reporting? – ViLar Jul 28 '20 at 09:04
  • 1
    I mean that it showed me the line and the file in which the error occurred. I mean the default php/apache error reporting. The new codeigniter way is nice and helpful but sometimes it doesn't help me to identify the error. – Dusan Jul 28 '20 at 14:24
  • In addition to my [previous comment](https://stackoverflow.com/questions/63129709/how-to-turn-off-the-new-codeigniter-4-error-reporting/63149779#comment119536370_63149779); I've started examining the app flow in CI4, and figured out a way to turn off fancy/json error output. Commenting out the `Services::exceptions()->initialize();` line in `system\CodeIgniter.php` in the `initialize()` method solved the problem. Now, I can see the original error output. – akinuri May 21 '21 at 12:17

1 Answers1

1

That is handled by the system/debug/Exceptions.php

At the moment there's no way of turning that off with just a setting. One way you can do what you want is to just edit the app/views/errors/html/error_exception.php to display just what you want and not all that.

marcogmonteiro
  • 2,061
  • 1
  • 17
  • 26
  • If I comment out the lines, I get some errors: Class 'Config\BaseConfig' not found. Also I can't find the $useKint option. I'm using Codeigniter version 4.0.4 – Dusan Jul 29 '20 at 11:54
  • @Dusan if you dont mind hacking at the core, you can see where all this happens here: https://github.com/codeigniter4/CodeIgniter4/blob/38017c58f2ef2a96602e96eab3b22377890a825b/system/Debug/Exceptions.php#L121 – marcogmonteiro Jul 29 '20 at 13:47
  • I would'n like to mess with the core. I'll take a look at the error view. Thank you! – Dusan Jul 30 '20 at 05:34
  • @Dusan Why is this answer accepted? I'm also looking for a way to disable fancy/json error reporting, and this answer doesn't solve the problem. Fancy/json error reporting is not strictly related to views. I'm making requests via Postman and I'm getting the errors in the JSON format. There are issues with the JSON output... There should be a more general/global solution to this. – akinuri May 20 '21 at 21:28
  • The new version of codeigniter 4.1 just came out. And with it the ability to override more easily core functionality. So basically you can now override the output methods to work the way you want. https://codeigniter.com/user_guide/extending/core_classes.html?highlight=override @akinuri – marcogmonteiro May 23 '21 at 08:34