Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
In my work I have come across numerous instances of 'lazy' error handling. By 'lazy' I mean doing as little if anything to distinguish between genuine errors and ones that might as well be turned into a warning.

In a typical web application, there are a lot of cases of invalid user input. Unfortunately, more often than not such exceptions are handled inappropriately at run-time. Here's an example. One particular web application that dealt with processing and displaying news items would always present a visitor with an error page whenever he’d follow a link with a ‘;’ at the end (e.g.;). This non-digit character would end up trailing at the end of the ‘id’ query parameter received by my script. Consequently, when plugged into an SQL query to retrieve article contents, nothing would be returned, resulting in an ‘article not found’ error page and a corresponding log entry.

By examining my web application logs and also checking pages for invalid URL links (with the ‘;’ at the end), I had a hard time figuring out where exactly those invalid URL links came from. To spare you some time and make a long story short, I did eventually discover one particular 3rd party opt-in email program that was at the root of the problem (hardships associated with the use of 3rd party tools well deserve a separate discussion ;]). For reasons not yet known to me, the program would include ill-formatted links in it’s bi-weekly newsletter emailed to our subscribers. This tool being somewhat outside of my reach (handled by our editorial / marketing staff), I clearly hand to handle the situation from my side as sensibly as possible.

Clearly my initial handling of the invalid article id was inappropriate. An extra non-digit character at the end of the id string does not warrant a critical error. Simply removing all non-digit characters from the id parameter value solved the problem, yet still let my code handle situations where indeed the id didn’t exist (expired article etc). So, the initial error handling was replaced with a simple warning log entry in case of a non-digit character in the id string, and an error log entry along with an error page for all other cases.

Obviously this is not something you’d call a hard-to-fix bug. However, I think it does point to one specific problem area in a number of web applications, or even system (back-end) tools. In my case, it did help me realize that I had many more similar situations where a critical error could be safely separated into lesser warnings and thus minimize affect on the end user (in my case, a user could still see the intended article despite of the invalid character). Certainly this involves more work for the developer and is not a consolation for many of us here who have been accustomed to cherish the virtue of ‘laziness’ ;-)

# Under Construction

In reply to Sensible error handling by vladb

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (4)
    As of 2021-04-10 15:18 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found