<?php
namespace Test\e2;
class EmptyCatch {
public function test() {
try {
$this->throw();
} catch(Exception $e) {}
}
public function throw() {
throw new Exception("test");
}
}
There is nothing wrong with catching an exception. The problem is
that Exception
can be anything. And when implementing this feature,
you probably are try to solve an issue that ran into.
Instead of catching \Exception
or Throwable
it will be better to create
a specific Throwable
class that specificies
what happened.
```php <?php
namespace Test\e2;
class EmptyCatch { public function test() { try { $this->throw(); } catch(TestFailedException $e) {} }
public function throw() {
throw new TestFailedException("test");
} } `