40fc3aa7658793cb6672088c13ef32ee6036336e.svn-base 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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('PolymorphicArgumentException', -1);
  20. $error['EN'][PolymorphicArgumentException] = "Invalid argument pattern for polymorphic function.";
  21. $error['FR'][PolymorphicArgumentException] = "Modèle inadmissible d'argument pour la fonction polymorphe.".
  22. $error['DE'][PolymorphicArgumentException] = "Unzulässiges Argumentmuster für polymorphe Funktion.";
  23. define('ArgumentTypeException', -2);
  24. $error['EN'][ArgumentTypeException] = "Invalid argument type.";
  25. $error['FR'][ArgumentTypeException] = "Type inadmissible d'argument.";
  26. $error['DE'][ArgumentTypeException] = "Unzulässige Argumentart.";
  27. define('ArgumentBoundsException', -3);
  28. $error['EN'][ArgumentBoundsException] = "Invalid argument range.";
  29. $error['FR'][ArgumentBoundsException] = "Gamme inadmissible d'argument.";
  30. $error['DE'][ArgumentBoundsException] = "Unzulässige Argumentstrecke.";
  31. define('MatrixDimensionException', -4);
  32. $error['EN'][MatrixDimensionException] = "Matrix dimensions are not equal.";
  33. $error['FR'][MatrixDimensionException] = "Les dimensions de Matrix ne sont pas égales.";
  34. $error['DE'][MatrixDimensionException] = "Matrixmaße sind nicht gleich.";
  35. define('PrecisionLossException', -5);
  36. $error['EN'][PrecisionLossException] = "Significant precision loss detected.";
  37. $error['FR'][PrecisionLossException] = "Perte significative de précision détectée.";
  38. $error['DE'][PrecisionLossException] = "Bedeutender Präzision Verlust ermittelte.";
  39. define('MatrixSPDException', -6);
  40. $error['EN'][MatrixSPDException] = "Can only perform operation on symmetric positive definite matrix.";
  41. $error['FR'][MatrixSPDException] = "Perte significative de précision détectée.";
  42. $error['DE'][MatrixSPDException] = "Bedeutender Präzision Verlust ermittelte.";
  43. define('MatrixSingularException', -7);
  44. $error['EN'][MatrixSingularException] = "Can only perform operation on singular matrix.";
  45. define('MatrixRankException', -8);
  46. $error['EN'][MatrixRankException] = "Can only perform operation on full-rank matrix.";
  47. define('ArrayLengthException', -9);
  48. $error['EN'][ArrayLengthException] = "Array length must be a multiple of m.";
  49. define('RowLengthException', -10);
  50. $error['EN'][RowLengthException] = "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. global $error;
  57. if (isset($errorNumber)) {
  58. if (isset($error[JAMALANG][$errorNumber])) {
  59. return $error[JAMALANG][$errorNumber];
  60. } else {
  61. return $error['EN'][$errorNumber];
  62. }
  63. } else {
  64. return ("Invalid argument to JAMAError()");
  65. }
  66. }