php5Exception.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * The VerboseException class adds level, code, file, and line info to a regular exception
  4. * so that PHP5 errors are as verbose as possible
  5. *
  6. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  7. * @copyright (c) 2003 amfphp.org
  8. * @package flashservices
  9. * @subpackage exception
  10. * @author Justin Watkins Original Design
  11. * @version $Id: AMFException.php,v 1.2 2005/04/02 18:37:23 pmineault Exp $
  12. */
  13. class VerboseException extends Exception
  14. {
  15. public $description;
  16. public $level;
  17. public $file;
  18. public $line;
  19. public $code;
  20. public $message;
  21. function VerboseException($string, $level, $file, $line)
  22. {
  23. $this->description = $string;
  24. $this->level = $level;
  25. $this->code = "AMFPHP_RUNTIME_ERROR";
  26. $this->file = $file;
  27. $this->line = $line;
  28. Exception::__construct($string);
  29. }
  30. }
  31. function amfErrorHandler($level, $string, $file, $line, $context)
  32. {
  33. //forget about errors not defined at reported
  34. $amfphpErrorLevel = $GLOBALS['amfphp']['errorLevel'];
  35. if( error_reporting() != 0 && ($amfphpErrorLevel | $level) == $amfphpErrorLevel )
  36. {
  37. throw new VerboseException($string, $level, $file, $line);
  38. }
  39. }
  40. set_error_handler("amfErrorHandler");
  41. ?>