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

DC dan.cynosure at dbmscan.com
Mon Mar 19 09:30:59 MDT 2007


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


More information about the FX.php_List mailing list