管理错误和成功消息和代码的好方法是什么?
目前我没有一个很好的系统来管理错误或成功消息,它们几乎是与代码内联编写的。 有人可以建议最佳实践或您正在做的事情,以便能够正确管理整个应用程序中的大量错误和成功消息。
想想国际化......一些应用程序将有语言文件,然后应用程序只是从特定文件中提取字符串......我正在考虑为错误和成功消息实现类似的概念,并且很好奇其他人做了什么线?
Currently I don't have a very good system for managing error or success messages, they are pretty much written inline with the code. Can someone suggest a best practice or something you are doing to be able to properly manage a large list of error and success messages through out an application.
Think internationalization ... some applications will have language files, then the app just pulls the strings from the specific file ... I'm thinking of implementing a similar concept for error and success messages and am curious what others have done along the same lines?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是我使用的一个函数:
它将向您提供 PHP 代码产生的所有错误和警告,并在有人访问包含错误的页面时为您创建一个错误页面。
希望这可以帮助!
Here is a function that I use:
it will give you all the errors and warnings that your PHP code produces, along with create an error page for you in the case that someone visits a page that contains an error.
Hope this helps!
由于我使用单访问点样式系统来引导应用程序并包含正确的文件(它基本上是一个控制器系统),因此我可以使用:
然后,当我想抛出错误时,我只需:
这是我批量管理错误的方法,但不是管理列表的方法。 我可以
grep
查找我发现的错误消息,但它并不是很有组织。Since I use a single-access-point style system that bootstraps the application and includes the correct file (it's basically a controller system) I can use:
Then when I want to throw an error I just:
This is how I manage errors by bulk, but not how I could manage a list. I could
grep
for error messages I find, it's not really very organised though.您可以使用 PHP Documentor 之类的工具,并在每个类的文档中包含错误和消息。
http://www.phpdoc.org/
You might use something like PHP Documentor and include errors and messages in the docs for each class.
http://www.phpdoc.org/