error.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 vlibMimeMail.
  17. * It handles all of the error reporting for vlibMimeMail.
  18. *
  19. * @author Kelvin Jones <kelvin@kelvinjones.co.uk>
  20. * @since 22/04/2002
  21. * @package vLIB
  22. * @access private
  23. */
  24. class vlibMimeMailError {
  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. 'VM_ERROR_INVALID_ERROR_CODE' => 'vlibMimeMail error: Invalid error raised.',
  32. 'VM_ERROR_NOFILE' => 'vlibMimeMail error: Attachment ('.$extra.') file not found.',
  33. 'VM_ERROR_BADEMAIL' => 'vlibMimeMail error: Email address ('.$extra.') not valid.',
  34. 'VM_ERROR_NOBODY' => 'vlibMimeMail error: Tried to send a message with no body.',
  35. 'VM_ERROR_CANNOT_SEND' => 'vlibMimeMail error: Tried to send a message without declaring a body or a recipient.'
  36. );
  37. $error_levels = array(
  38. 'VM_ERROR_INVALID_ERROR_CODE' => FATAL,
  39. 'VM_ERROR_NOFILE' => FATAL,
  40. 'VM_ERROR_BADEMAIL' => FATAL,
  41. 'VM_ERROR_NOBODY' => FATAL,
  42. 'VM_ERROR_CANNOT_SEND' => FATAL
  43. );
  44. if ($level === null) $level = $error_levels[$code];
  45. if ($msg = $error_codes[$code]) {
  46. trigger_error($msg, $level);
  47. } else {
  48. trigger_error($error_codes['VM_ERROR_INVALID_ERROR_CODE'], $error_levels['VM_ERROR_INVALID_ERROR_CODE']);
  49. }
  50. return;
  51. }
  52. }
  53. ?>