Home page Home page Home page Home page
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel
By Sprezz | Friday, 25 June 2010 14:58 | 0 Comments
Here at Sprezz Towers we're big fans of trying to write clean, maintainable code that lends itself to easy modification. As part of this, we like to keep our resource strings in a separate configuration row and pull them in at runtime using a call to one of our function libraries.

Today this technique rose up and bit us on the proverbial... consider the following code :-

begin case
  case memberRelatedCall= ''
    //* CTC012: Member call question must be answered|
    errorText := zzx_Utility( "RESSTR", RESKEY2$, "CTC012", "", 1)

You'll see that as a friendly reminder to following programmers we include the text of the error message as a comment before the call to retrieve the error text.

We were unit testing a module and ensuring that the appropriate errors messages were displayed when error conditions were found. But try as we might we couldn't get the errors to display and clearly incorrect data was somehow escaping validation.

This frustrated us no end. We single stepped through code and whilst the error condition was clearly there we just couldn't get it to set the error text to flag the exception. Even more mysteriously in the debugger we couldn't get the cursor to stop on the assignment of the error text.

Finally light dawned. As we were building up a potentially long error message we were including pipes in the literal as above. And whilst a pipe in a message means new line a pipe on the end of a program statement means the opposite - continue line. So our error text assignment was being seen as a comment and was not acted upon.

Of course if we'd thought to use #PRAGMA OUTPUT Table Row our mistake would have become immediately apparent.... hindsight eh?

As Homer so accurately says... D'oh!


Post a Comment

Subscribe to Post Comments [Atom]

<< Home

Pixel Footer R1 C1 Pixel