[FX.php List] Snippet: Displaying Error Code Messages

Jonathan Schwartz jonathan at exit445.com
Mon Mar 19 11:11:39 MDT 2007


Well...yes.  For a beginner, arrays are some unknown (Don't Ask, 
Don't Tell) entity that work mysteriously behind the scenes.  Only at 
the point when a developer is forced to reckon with them, do their 
true power become apparent.  Then you don't know how you managed 
without them.

J

At 11:30 AM -0400 3/19/07, DC wrote:
>Hey, that's great! Array-phobia... hmmm is that like a fear of large 
>collections with unknown types?
>
>Thanks,
>dan
>
>Jonathan Schwartz had written:
>>Hi Folks,
>>
>>Wanted to offer up a simple little snippet that I created today to 
>>help with error reporting.  Experienced fx.php users may already be 
>>using this technique....so this is for the beginners/intermediate 
>>fx.php users.
>>
>>Up to this time, I have been using the FMErrors.php file as a 
>>simple reference tool to look up the meaning of error codes thrown 
>>by FMP/fx.php.  The file is buried deep in the FX folder. That gets 
>>tired after the 1,000th time.  On my last iteration, I realized 
>>that the file is actually an array: the error number is the key and 
>>the error phrase is the value.  Now that I am past my array-phobia, 
>>the answer seems clear. By simply requesting the value associated 
>>with the current error number (key), the error phrase can easily be 
>>displayed, like this:
>>
>>include(FMErrors.php);
>><snip>
>>if($searchResult['errorCode'] != '0' && $searchResult['errorCode'] != '401')
>>{
>>$msg = 'Oops! Your search didn\'t return any results due to a 
>>problem: Error#'.$searchResult['errorCode']. ' 
>>'.$errorsList[$searchResult['errorCode']];
>>}
>>...and then display the $msg where appropriate.
>>
>>
>>In this case, I have assumed that all errors other than  "0" (No 
>>error) and "401" (No records found) are problems, and that the 
>>message should be displayed.  Your mileage may vary.
>>
>>HTH,
>>
>>Jonathan
>_______________________________________________
>FX.php_List mailing list
>FX.php_List at mail.iviking.org
>http://www.iviking.org/mailman/listinfo/fx.php_list


-- 
Jonathan Schwartz
Exit 445 Group
jonathan at exit445.com
http://www.exit445.com
415-381-1852
FileMaker 8 Certified Developer


More information about the FX.php_List mailing list