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! ! ! ! !
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
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.