![]() |
![]() |
![]()
Post
#1
|
|
![]() Grupa: Zarejestrowani Postów: 144 Pomógł: 0 Dołączył: 15.09.2016 Skąd: Warszawa Ostrzeżenie: (0%) ![]() ![]() |
http://www.brandonsavage.net/exceptional-p...-to-exceptions/
Cytat Be sure that your exceptions honor layer abstraction. One of the more complicated things about handling exceptions is that you want to honor layer abstraction when throwing and catching exceptions. For example, let’s say that PDO raises an exception due to a unique key constraint in the database. Unhandled, it will bubble up to the top. If the PDO exception was caused by something in your Controller, allowing the PDO exception to bubble up would be a violation of layer abstraction. A better choice would be to catch the PDO exception and wrap it in a Controller exception. For example:
Cytat When the exception bubbles up, the PDO exception will have been handled, but the message will be included in a ControllerException. This is an acceptable way to handle exceptions that honors the principle of layer abstraction. Nie rozumiem po co owijanie wyjątków i wyrzucanie kolejnych. W czym to ma pomóc? I tak na końcu widzę na ekranie (Symfony profiler) komunikat o błędzie i linię z błędem. Co mi daje inna nazwa klasy exception? Bo, wcześniej se zanotowałem z innych internetów, przypadki ponownego wyrzucania wyjątków (owijania):
No ale przykład z bloga mi nie pasuje do niczego z powyższych. Ten post edytował porzeczki 30.12.2016, 15:05:52 |
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 25.06.2025 - 12:12 |