Troubleshooting of Sonar issue: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
No edit summary
Line 22: Line 22:
== Further reading ==
== Further reading ==
* [https://www.php.net/manual/en/spl.exceptions.php PHP: Exceptions - Manual]
* [https://www.php.net/manual/en/spl.exceptions.php PHP: Exceptions - Manual]
* [http://asika.windspeaker.co/post/3503-php-exceptions PHP Exceptions 種類與使用情境說明 | Asika Lab 飛鳥實驗室]


== References ==
== References ==

Revision as of 16:48, 7 September 2023


icon_scale_pencil.png This article "Troubleshooting of Sonar issue" is still being written. If there are any incomplete parts, you are welcome to directly edit them. 這篇文章「Troubleshooting of Sonar issue」內容還在撰寫中,如果有不完整的部分,歡迎你直接動手修改


How to resolve "Define and throw a dedicated exception instead of using a generic one"

Error condition which met "Define and throw a dedicated exception instead of using a generic one" [1]

if(!is_null($some_variable)){
            $error = 'The variable $some_variable is not defined.';
            throw new Exception($error);
        }

Possible solution

if(!is_null($some_variable)){
            $error = 'The variable $some_variable is not defined.';
            throw new InvalidArgumentException($error);
        }

Further reading

References


Troubleshooting of ...

Template