1.2.1249. Undefined Caught Exceptions¶
Those are exceptions that are caught in the code, but are not defined in the application.
They may be externally defined, such as in core PHP, extensions or libraries. Make sure those exceptions are useful to your application : otherwise, they are dead code.
<?php
try {
library_function($some, $args);
} catch (LibraryException $e) {
// This exception is not defined, and probably belongs to Library
print "Library failed\n";
} catch (OtherLibraryException $e) {
// This exception is not defined, and probably do not belongs to this code
print "Library failed\n";
} catch (\Exception $e) {
// This exception is a PHP standard exception
print "Something went wrong, but not at Libary level\n";
}
?>
1.2.1249.1. Connex PHP features¶
1.2.1249.1.1. Suggestions¶
Remove the catch clause, as it is dead code
Make sure the exception is thrown by the underlying code
1.2.1249.1.2. Specs¶
Short name |
Exceptions/CaughtButNotThrown |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
|
Time To Fix |
|
Precision |
High |
Available in |