在典型的MVC应用程序中,您有许多层。
数据库层模型层(可能与数据库在同一个包中)视图/ UI层控制器层业务层
如果要在足够复杂的MVC应用程序中创建错误日志记录的自定义异常,接口和模型,那么异常处理或错误日志记录应该放在何处?
In your typical MVC application, you have many layers.
Database layer Model layer (possibly in the same package as the DB) View/UI Layer Controller Layer Business Layer
Where should the exception handling or error logging live here, if you were to create custom exceptions, interfaces and models for error logging in a sufficiently complex MVC application?
最满意答案
您应该在数据层中处理来自数据层的异常(例如,SQLExceptions),控制器中的异常,控制器/逻辑异常以及显示相关异常的视图。 使用像ELMAH这样的日志记录解决方案来记录异常并捕获未处理的异常。
You should handle exceptions in your data layer that come from your data layer (SQLExceptions, for example), in your controller for controller/logic exceptions, and in your view for display related exceptions. Use a logging solution like ELMAH to log exceptions and catch unhandled exceptions.
更多推荐
发布评论