c# - Are exceptions caught in the presentation layer during project development?
天蓬老师
天蓬老师 2017-05-16 17:05:43
0
2
902

In actual projects, the business logic layer and service layer only throw exceptions but do not handle them.
Are exceptions caught and processed in the presentation layer (logging or something)?

It seems that this does not apply if the front and back ends are separated. Exception capture needs to be captured where the service or logic is called? Is that so,

What is the exception handling in your actual project? Please give me some pointers! ! ! ! !

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
漂亮男人

The service layer will do logging. Generally speaking, exceptions thrown are caught by the presentation layer, but they will also be captured and logged first in the service layer and then thrown

Ty80

First of all, we need to clarify a concept: exceptions are thrown to programmers, not to users.

After clarifying this concept, it is easy to understand why exceptions need to be handled in the presentation layer - because the presentation layer is the last barrier between programmers and users, exceptions must be packaged beautifully and thrown to the customer, that is The so-called user experience.

However, the presentation layer is definitely not the only place that needs to handle exceptions. Those places you mentioned, including the bottom layer, the server... all need to handle exceptions appropriately.

For example, the interface provided by the server generally takes the caller's experience into consideration, so it will not throw an exception directly, but needs to be encapsulated to a certain extent, and at the same time, the exception information is recorded on the server for error checking.

Of course, in order to simplify and unify the processing process, exception processing is usually concentrated at certain levels, including the presentation layer.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!