Каковы наилучшие методы перехвата и повторного создания исключений? ⇐ Php
Каковы наилучшие методы перехвата и повторного создания исключений?
Should caught exceptions be re-thrown directly, or should they be wrapped around a new exception?
That is, should I do this:
try { $connect = new CONNECT($db, $user, $password, $driver, $host); } catch (Exception $e) { throw $e; } or this:
try { $connect = new CONNECT($db, $user, $password, $driver, $host); } catch (Exception $e) { throw new Exception("Exception Message", 1, $e); } If your answer is to throw directly please suggest the use of exception chaining, I am not able to understand a real world scenario where we use exception chaining.
Источник: https://stackoverflow.com/questions/555 ... exceptions
Should caught exceptions be re-thrown directly, or should they be wrapped around a new exception?
That is, should I do this:
try { $connect = new CONNECT($db, $user, $password, $driver, $host); } catch (Exception $e) { throw $e; } or this:
try { $connect = new CONNECT($db, $user, $password, $driver, $host); } catch (Exception $e) { throw new Exception("Exception Message", 1, $e); } If your answer is to throw directly please suggest the use of exception chaining, I am not able to understand a real world scenario where we use exception chaining.
Источник: https://stackoverflow.com/questions/555 ... exceptions
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Каковы наилучшие методы реализации полноэкранных уведомлений о вызовах на Android?
Anonymous » » в форуме JAVA - 0 Ответы
- 31 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Каковы наилучшие методы реализации полноэкранных уведомлений о вызовах на Android?
Anonymous » » в форуме Android - 0 Ответы
- 22 Просмотры
-
Последнее сообщение Anonymous
-