error.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4.0 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 2002 Active Fish Group |
  7. // +----------------------------------------------------------------------+
  8. // | Authors: Kelvin Jones <kelvin@kelvinjones.co.uk> |
  9. // +----------------------------------------------------------------------+
  10. //
  11. // $Id: error.php 1438 2006-10-29 13:26:42Z b4rt $
  12. if (!defined('FATAL')) define('FATAL', E_USER_ERROR);
  13. if (!defined('WARNING')) define('WARNING', E_USER_WARNING);
  14. if (!defined('NOTICE')) define('NOTICE', E_USER_NOTICE);
  15. /**
  16. * Class is used by vlibDate.
  17. * It handles all of the error reporting for vlibDate.
  18. *
  19. * @author Kelvin Jones <kelvin@kelvinjones.co.uk>
  20. * @since 26/04/2002
  21. * @package vLIB
  22. * @access private
  23. */
  24. class vlibDateError {
  25. /*-----------------------------------------------------------------------------\
  26. | DO NOT TOUCH ANYTHING IN THIS CLASS IT MAY NOT WORK OTHERWISE |
  27. \-----------------------------------------------------------------------------*/
  28. function raiseError ($code, $level = null, $extra=null) {
  29. if (!($level & error_reporting())) return; // binary AND checks for reporting level
  30. $error_codes = array(
  31. 'VD_ERROR_INVALID_ERROR_CODE' => 'vlibDate error: Invalid error raised.',
  32. 'VD_ERROR_INVALID_LANG' => 'vlibDate error: Invalid language code used.',
  33. 'VD_ERROR_INVALID_TIMESTAMP' => 'vlibDate error: Invalid timstamp used.'
  34. );
  35. $error_levels = array(
  36. 'VD_ERROR_INVALID_ERROR_CODE' => FATAL,
  37. 'VD_ERROR_INVALID_LANG' => FATAL,
  38. 'VD_ERROR_INVALID_TIMESTAMP' => FATAL
  39. );
  40. if ($level === null) $level = $error_levels[$code];
  41. if ($msg = $error_codes[$code]) {
  42. trigger_error($msg, $level);
  43. } else {
  44. trigger_error($error_codes['VD_ERROR_INVALID_ERROR_CODE'], $error_levels['VD_ERROR_INVALID_ERROR_CODE']);
  45. }
  46. return;
  47. }
  48. }
  49. ?>