slimphp/Slim

Error handling still problematic

开放

#3,287 创建于 2023年9月20日

 (9 条评论) (1 个反应) (0 位负责人)PHP (1,970 个派生)batch import
Slim 5help wanted

仓库指标

星标
 (12,257 个星标)
PR 合并指标
 (平均合并 25天 18小时) (30 天内合并 4 个 PR)

描述

This issue had been raised before. A lot of boilerplate code is needed to implement error handling, but the main problem is how Slim handles and overrides this internally, and then the order of defining middlewares and error handling in a complex application, you should not have to read the docs for this, cause if you miss it or do it wrong then your error handling will not work correctly. Imagine a typical scenario where you need to handle and log ALL types of errors gracefully with your own views loggers etc, including fatal errors, this means in some cases your error handling needs to be "active" even before Slim boots, now reading the docs and tutorials it becomes an absolute verbose mess.

I've been working with Slim for a few years and error handling remains a pain point. Can I suggest that you either remove error handling completely from the core and only throw, and the developer can wrap the application with error handlers any way he/she sees fit. Or at least supply a configuration option to disable Slim's error handling completely. Its really a trivial matter and should not be this complicated.

贡献者指南