JAMA
[ class tree: JAMA ] [ index: JAMA ] [ all elements ]

Source for file Error.php

Documentation is available at Error.php

  1. <?php
  2. /**
  3. @package JAMA
  4. *  Error handling
  5. @author Michael Bommarito
  6. @version 01292005
  7. */
  8.  
  9. //Language constant
  10. define('LANG''EN');
  11.  
  12.  
  13. //Error type constants
  14. define('ERROR'E_USER_ERROR);
  15. define('WARNING'E_USER_WARNING);
  16. define('NOTICE'E_USER_NOTICE);
  17.  
  18. //All errors may be defined by the following format:
  19. //define('ExceptionName', N);
  20. //$error['lang'][N] = 'Error message';
  21. $error array();
  22.  
  23. /*
  24. I've used Babelfish and a little poor knowledge of Romance/Germanic languages for the translations
  25. here.  Feel free to correct anything that looks amiss to you.
  26. */
  27.  
  28. define('PolymorphicArgumentException'-1);
  29. $error['EN'][-1"Invalid argument pattern for polymorphic function.";
  30. $error['FR'][-1"Modèle inadmissible d'argument pour la fonction polymorphe.".
  31. $error['DE'][-1"Unzulässiges Argumentmuster für polymorphe Funktion.";
  32.  
  33. define('ArgumentTypeException'-2);
  34. $error['EN'][-2"Invalid argument type.";
  35. $error['FR'][-2"Type inadmissible d'argument.";
  36. $error['DE'][-2"Unzulässige Argumentart.";
  37.  
  38. define('ArgumentBoundsException'-3);
  39. $error['EN'][-3"Invalid argument range.";
  40. $error['FR'][-3"Gamme inadmissible d'argument.";
  41. $error['DE'][-3"Unzulässige Argumentstrecke.";
  42.  
  43. define('MatrixDimensionException'-4);
  44. $error['EN'][-4"Matrix dimensions are not equal.";
  45. $error['FR'][-4"Les dimensions de Matrix ne sont pas égales.";
  46. $error['DE'][-4"Matrixmaße sind nicht gleich.";
  47.  
  48. define('PrecisionLossException'-5);
  49. $error['EN'][-5"Significant precision loss detected.";
  50. $error['FR'][-5"Perte significative de précision détectée.";
  51. $error['DE'][-5"Bedeutender Präzision Verlust ermittelte.";
  52.  
  53. define('MatrixSPDException'-6);
  54. $error['EN'][-6"Can only perform operation on symmetric positive definite matrix.";
  55. $error['FR'][-6"Perte significative de précision détectée.";
  56. $error['DE'][-6"Bedeutender Präzision Verlust ermittelte.";
  57.  
  58. define('MatrixSingularException'-7);
  59. $error['EN'][-7"Can only perform operation on singular matrix.";
  60.  
  61. define('MatrixRankException'-8);
  62. $error['EN'][-8"Can only perform operation on full-rank matrix.";
  63.  
  64. define('ArrayLengthException'-9);
  65. $error['EN'][-9"Array length must be a multiple of m.";
  66.  
  67. define('RowLengthException'-10);
  68. $error['EN'][-10"All rows must have the same length.";
  69.  
  70. /**
  71. * Custom error handler
  72. @param int $type Error type: {ERROR, WARNING, NOTICE}
  73. @param int $num Error number
  74. @param string $file File in which the error occured
  75. @param int $line Line on which the error occured
  76. */
  77. function JAMAError$type null$num null$file null$line null$context null {
  78.   global $error;
  79.   
  80.   $lang LANG;
  81.   ifisset($type&& isset($num&& isset($file&& isset($line) )  {
  82.     switch$type {
  83.       case ERROR:
  84.         echo '<div class="errror"><b>Error:</b> ' $error[$lang][$num'<br />' $file ' @ L' $line '</div>';
  85.         die();
  86.         break;
  87.       
  88.       case WARNING:
  89.         echo '<div class="warning"><b>Warning:</b> ' $error[$lang][$num'<br />' $file ' @ L' $line '</div>';
  90.         break;
  91.       
  92.       case NOTICE:
  93.         //echo '<div class="notice"><b>Notice:</b> ' . $error[$lang][$num] . '<br />' . $file . ' @ L' . $line . '</div>';
  94.         break;
  95.  
  96.       case E_NOTICE:
  97.         //echo '<div class="errror"><b>Notice:</b> ' . $error[$lang][$num] . '<br />' . $file . ' @ L' . $line . '</div>';
  98.         break;
  99.  
  100.       case E_STRICT:
  101.         break;
  102.         
  103.       case E_WARNING:
  104.           break;
  105.  
  106.       default:
  107.         echo "<div class=\"error\"><b>Unknown Error Type:</b> $type - $file @ L{$line}</div>";
  108.         die();
  109.         break;
  110.     }
  111.   else {
  112.     die"Invalid arguments to JAMAError()" );
  113.   }
  114. }
  115.  
  116. set_error_handler('JAMAError');
  117. ?>

Documentation generated on Mon, 05 Jan 2009 20:36:53 +0100 by phpDocumentor 1.4.1