Code Smell 166 — Low-Level Errors on User Interface

Code Smell 166 — Low-Level Errors on User InterfaceFatal 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 718TL;DR: Catch your errors. Eve…


This content originally appeared on Level Up Coding - Medium and was authored by Maximiliano Contieri

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

  1. Use a top-level handler
  2. Avoid languages favoring return codes
  3. 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 function
function myException($exception) {
logError($exception->description())
// We don't show Exception to final users
}
// Set user-defined exception handler function
set_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

More Info

Fail Fast

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

This article is part of the CodeSmell Series.

How to Find the Stinky parts of your Code


Code Smell 166 — Low-Level Errors on User Interface was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Maximiliano Contieri


Print Share Comment Cite Upload Translate Updates
APA

Maximiliano Contieri | Sciencx (2022-09-30T11:33:17+00:00) Code Smell 166 — Low-Level Errors on User Interface. Retrieved from https://www.scien.cx/2022/09/30/code-smell-166-low-level-errors-on-user-interface/

MLA
" » Code Smell 166 — Low-Level Errors on User Interface." Maximiliano Contieri | Sciencx - Friday September 30, 2022, https://www.scien.cx/2022/09/30/code-smell-166-low-level-errors-on-user-interface/
HARVARD
Maximiliano Contieri | Sciencx Friday September 30, 2022 » Code Smell 166 — Low-Level Errors on User Interface., viewed ,<https://www.scien.cx/2022/09/30/code-smell-166-low-level-errors-on-user-interface/>
VANCOUVER
Maximiliano Contieri | Sciencx - » Code Smell 166 — Low-Level Errors on User Interface. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/09/30/code-smell-166-low-level-errors-on-user-interface/
CHICAGO
" » Code Smell 166 — Low-Level Errors on User Interface." Maximiliano Contieri | Sciencx - Accessed . https://www.scien.cx/2022/09/30/code-smell-166-low-level-errors-on-user-interface/
IEEE
" » Code Smell 166 — Low-Level Errors on User Interface." Maximiliano Contieri | Sciencx [Online]. Available: https://www.scien.cx/2022/09/30/code-smell-166-low-level-errors-on-user-interface/. [Accessed: ]
rf:citation
» Code Smell 166 — Low-Level Errors on User Interface | Maximiliano Contieri | Sciencx | https://www.scien.cx/2022/09/30/code-smell-166-low-level-errors-on-user-interface/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.