An Interest In:
Web News this Week
- March 5, 2024
- March 4, 2024
- March 3, 2024
- March 2, 2024
- March 1, 2024
- February 29, 2024
- February 28, 2024
Code Smell 166 - Low-Level Errors on User Interface
Fatal error: Uncaught Error: Class 'logs_queries_web' not found in /var/www/html/query-line.php:78 Stack trace: #0 {main} thrown in /var/www/html/query-line.php on line 718
TL;DR: Catch your errors. Even the ones you don't expect.
Problems
Security
Error Handling
Error Logging
Bad UX Experience
Solutions
Use a top-level handler
Avoid languages favoring return codes
Expect database and low-level errors
Context
Even in 2022, we can see "serious" websites showing casual users a stack or debugging message.
Sample Code
Wrong
<?Fatal error: Uncaught Error: Class 'MyClass' not found in /nstest/src/Container.php:9
Right
<?// A user-defined exception handler functionfunction myException($exception) { logError($exception->description()) // We don't show Exception to final users }// Set user-defined exception handler functionset_exception_handler("myException");
Detection
[X] Automatic
We can use mutation testing to simulate problems and see if they are handled correctly.
Tags
- Security
Conclusion
We need to keep maturing.
Our solutions shouldn't be sloppy.
We need to improve our reputation as serious software engineers.
Relations
Code Smell 72 - Return Codes
Maxi Contieri May 28 '21 2 min read
More Info
Disclaimer
Code Smells are just my opinion.
Credits
Photo by jesse orrico on Unsplash
80 percent of my problems are simple logic errors. 80 percent of the remaining problems are pointer errors. The remaining problems are hard.
Mark Donner
Software Engineering Great Quotes
Maxi Contieri Dec 28 '20 13 min read
This article is part of the CodeSmell Series.
Original Link: https://dev.to/mcsee/code-smell-166-low-level-errors-on-user-interface-4iid
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To