Error.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * @package JAMA
  4. *
  5. * Error handling
  6. * @author Michael Bommarito
  7. * @version 01292005
  8. */
  9. //Language constant
  10. define('JAMALANG', 'EN');
  11. //All errors may be defined by the following format:
  12. //define('ExceptionName', N);
  13. //$error['lang'][ExceptionName] = 'Error message';
  14. $error = array();
  15. /*
  16. I've used Babelfish and a little poor knowledge of Romance/Germanic languages for the translations here.
  17. Feel free to correct anything that looks amiss to you.
  18. */
  19. define('POLYMORPHIC_ARGUMENT_EXCEPTION', -1);
  20. $error['EN'][POLYMORPHIC_ARGUMENT_EXCEPTION] = "Invalid argument pattern for polymorphic function.";
  21. $error['FR'][POLYMORPHIC_ARGUMENT_EXCEPTION] = "Modèle inadmissible d'argument pour la fonction polymorphe.".
  22. $error['DE'][POLYMORPHIC_ARGUMENT_EXCEPTION] = "Unzulässiges Argumentmuster für polymorphe Funktion.";
  23. define('ARGUMENT_TYPE_EXCEPTION', -2);
  24. $error['EN'][ARGUMENT_TYPE_EXCEPTION] = "Invalid argument type.";
  25. $error['FR'][ARGUMENT_TYPE_EXCEPTION] = "Type inadmissible d'argument.";
  26. $error['DE'][ARGUMENT_TYPE_EXCEPTION] = "Unzulässige Argumentart.";
  27. define('ARGUMENT_BOUNDS_EXCEPTION', -3);
  28. $error['EN'][ARGUMENT_BOUNDS_EXCEPTION] = "Invalid argument range.";
  29. $error['FR'][ARGUMENT_BOUNDS_EXCEPTION] = "Gamme inadmissible d'argument.";
  30. $error['DE'][ARGUMENT_BOUNDS_EXCEPTION] = "Unzulässige Argumentstrecke.";
  31. define('MATRIX_DIMENSION_EXCEPTION', -4);
  32. $error['EN'][MATRIX_DIMENSION_EXCEPTION] = "Matrix dimensions are not equal.";
  33. $error['FR'][MATRIX_DIMENSION_EXCEPTION] = "Les dimensions de Matrix ne sont pas égales.";
  34. $error['DE'][MATRIX_DIMENSION_EXCEPTION] = "Matrixmaße sind nicht gleich.";
  35. define('PRECISION_LOSS_EXCEPTION', -5);
  36. $error['EN'][PRECISION_LOSS_EXCEPTION] = "Significant precision loss detected.";
  37. $error['FR'][PRECISION_LOSS_EXCEPTION] = "Perte significative de précision détectée.";
  38. $error['DE'][PRECISION_LOSS_EXCEPTION] = "Bedeutender Präzision Verlust ermittelte.";
  39. define('MATRIX_SPD_EXCEPTION', -6);
  40. $error['EN'][MATRIX_SPD_EXCEPTION] = "Can only perform operation on symmetric positive definite matrix.";
  41. $error['FR'][MATRIX_SPD_EXCEPTION] = "Perte significative de précision détectée.";
  42. $error['DE'][MATRIX_SPD_EXCEPTION] = "Bedeutender Präzision Verlust ermittelte.";
  43. define('MATRIX_SINGULAR_EXCEPTION', -7);
  44. $error['EN'][MATRIX_SINGULAR_EXCEPTION] = "Can only perform operation on singular matrix.";
  45. define('MATRIX_RANK_EXCEPTION', -8);
  46. $error['EN'][MATRIX_RANK_EXCEPTION] = "Can only perform operation on full-rank matrix.";
  47. define('ARRAY_LENGTH_EXCEPTION', -9);
  48. $error['EN'][ARRAY_LENGTH_EXCEPTION] = "Array length must be a multiple of m.";
  49. define('ROW_LENGTH_EXCEPTION', -10);
  50. $error['EN'][ROW_LENGTH_EXCEPTION] = "All rows must have the same length.";
  51. /**
  52. * Custom error handler
  53. * @param int $num Error number
  54. */
  55. function JAMAError($errorNumber = null)
  56. {
  57. global $error;
  58. if (isset($errorNumber)) {
  59. if (isset($error[JAMALANG][$errorNumber])) {
  60. return $error[JAMALANG][$errorNumber];
  61. } else {
  62. return $error['EN'][$errorNumber];
  63. }
  64. } else {
  65. return ("Invalid argument to JAMAError()");
  66. }
  67. }