Troubleshooting of Sonar issue: Difference between revisions
Jump to navigation
Jump to search
m
→How to resolve "Define and throw a dedicated exception instead of using a generic one"
m (→References) |
|||
| Line 6: | Line 6: | ||
Error condition which met "Define and throw a dedicated exception instead of using a generic one" <ref>[https://cwe.mitre.org/data/definitions/397 CWE - CWE-397: Declaration of Throws for Generic Exception (4.12)]</ref> | Error condition which met "Define and throw a dedicated exception instead of using a generic one" <ref>[https://cwe.mitre.org/data/definitions/397 CWE - CWE-397: Declaration of Throws for Generic Exception (4.12)]</ref> | ||
<pre> | <pre> | ||
if( | if(is_null($some_variable)){ | ||
$error = 'The variable $some_variable is not defined.'; | $error = 'The variable $some_variable is not defined.'; | ||
throw new Exception($error); | throw new Exception($error); | ||