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