0
UPDATE를 슬로우 다시해야합니다 내가 이런 걸하고 싶지 : eatch 구성 요소가 내 프레임 워크에서 각 프레임 워크의 구성 요소PHP는 예외 : 예외
<?php
class ClassA {
public function doSomething() {
throw new ClassA\Exception\BadMethodCallException('bad method called');
}
}
class Application {
public function MainMethod() {
$ClassA = new ClassA();
$ClassA->doSomething();
}
}
try {
$Application = new Application();
$Application->MainMethod();
} catch(\Application\Exception $e) {
// exception cannot be catched, because ClassA\Exception\BadMethodCallException was thrown
}
?>
마다 별도의 예외가 필요 http://framework.zend.com/wiki/display/ZFDEV2/Proposal+for+Exceptions+in+ZF2 그게 방법을 그 자신의 예외 클래스. 나는 당신의 문제에 대한 해결책의 많은이없는
<?php
class Application {
public function MainMethod() {
$ClassA = new ClassA();
try {
$ClassA->doSomething();
} catch(\ClassA\Exception\BadMethodCallException $e) {
throw new Application\Exception\BadMethodCallException('message', null, $e);
}
}
}
?>
그 정도면 'try/catch' 문이 너무 많아 질 것입니다. 모든 예외 수업에 대한 동기는 무엇입니까? 예외를 추적 할 수 있도록하려면 하나 또는 두 개의 예외 클래스를 사용하여 예외에 파일/클래스 이름을 인쇄 할 수 있습니다. – Alex