Ignore:
Timestamp:
Sep 5, 2008, 3:24:01 AM (16 years ago)
Author:
rvelices
Message:
  • better management of fatal errors (instead of die or trigger_error rather use fatal_error ...)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions.inc.php

    r2497 r2502  
    233233    if ($mkd==false)
    234234    {
    235       !($flags&MKGETDIR_DIE_ON_ERROR) or trigger_error( "$dir ".l10n('no_write_access'), E_USER_ERROR);
     235      !($flags&MKGETDIR_DIE_ON_ERROR) or fatal_error( "$dir ".l10n('no_write_access'));
    236236      return false;
    237237    }
     
    251251    if ( !is_writable($dir) )
    252252    {
    253       !($flags&MKGETDIR_DIE_ON_ERROR) or trigger_error( "$dir ".l10n('no_write_access'), E_USER_ERROR);
     253      !($flags&MKGETDIR_DIE_ON_ERROR) or fatal_error( "$dir ".l10n('no_write_access'));
    254254      return false;
    255255    }
     
    946946// my_error returns (or send to standard output) the message concerning the
    947947// error occured for the last mysql query.
    948 
    949948function my_error($header, $die)
    950949{
    951   $error = $header;
    952   $error.= "\n[mysql error ".mysql_errno().'] '.mysql_error()."\n";
    953 
    954   if (function_exists('debug_backtrace'))
    955   {
    956     $bt = debug_backtrace();
    957     for ($i=0; $i<count($bt); $i++)
    958     {
    959       $error .= "#$i\t".@$bt[$i]['function']." ".@$bt[$i]['file']."(".@@$bt[$i]['line'].")\n";
    960     }
    961   }
     950  $error = "[mysql error ".mysql_errno().'] '.mysql_error()."\n";
     951  $error .= $header;
    962952
    963953  if ($die)
    964954  {
    965     @set_status_header(500);
    966     echo( str_repeat( ' ', 300)."\n"); //IE doesn't error output if below a size
     955    fatal_error($error);
    967956  }
    968957  echo("<pre>");
    969   trigger_error($error, $die ? E_USER_ERROR : E_USER_WARNING);
    970   !$die || die($error); // just in case the handler didnt die
     958  trigger_error($error, E_USER_WARNING);
    971959  echo("</pre>");
    972960}
     
    11381126  else
    11391127  {
    1140     die('l10n_args: Invalid arguments');
     1128    fatal_error('l10n_args: Invalid arguments');
    11411129  }
    11421130
     
    12221210  if ((mysql_num_rows($result) == 0) and !empty($condition))
    12231211  {
    1224     die('No configuration data');
     1212    fatal_error('No configuration data');
    12251213  }
    12261214
     
    13721360function get_pwg_charset()
    13731361{
    1374   defined('PWG_CHARSET') or die('load_language PWG_CHARSET undefined');
     1362  defined('PWG_CHARSET') or fatal_error('load_language PWG_CHARSET undefined');
    13751363  return PWG_CHARSET;
    13761364}
Note: See TracChangeset for help on using the changeset viewer.