<<< Previous question <<< Question ID#0778.md >>> Next question >>>
Give the following code?
try {
// ...
} catch (MyEx1 $e) {
logError($e);
} catch (MyEx2 $e) {
logError($e);
} catch (MyEx3 $e) {
logError($e);
}
Since all "catch" blocks have the same code, how can you avoid duplication here?
- A) "catch(MyEx1 | MyEx2 | MyEx3 $e)";
- B) By replacing the "catch" blocks with one "finally" block;
- C) By catching any like this: "catch(Exception $e)";
- D) "catch(MyEx1, MyEx2, MyEx3 $e)";
Answer
Answer: A