Source for file throw.inc.php

Documentation is available at throw.inc.php

  1. <?php
  2.  
  3. /**
  4. * Defines the throw functions.
  5. *
  6. * @package harmoni.error_handler
  7. *
  8. * @copyright Copyright &copy; 2005, Middlebury College
  9. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  10. *
  11. * @version $Id: throw.inc.php,v 1.15 2007/09/19 14:04:09 adamfranco Exp $
  12. */
  13.  
  14. /**
  15. * Throws an error using the ErrorHandler.
  16. * @param object Error The error object to throw.
  17. */
  18. function throwError($error) {
  19. // new implementation for PHP 5
  20. throw $error;
  21. }
  22.  
  23. /**
  24. * Prints a debug_backtrace() array in a pretty HTML way...
  25. * @param optional array $trace The array. If null, a current backtrace is used.
  26. * @param optional boolean $return If true will return the HTML instead of printing it.
  27. * @access public
  28. * @return void
  29. */
  30. function printDebugBacktrace($trace = null, $return=false)
  31. {
  32. $traceArray = is_array($trace)?$trace:debug_backtrace();
  33.  
  34. if ($return) ob_start();
  35. print "\n\n<table border='1'>";
  36. print "\n\t<thead>";
  37. print "\n\t\t<tr>";
  38. print "\n\t\t\t<th>#</th>";
  39. print "\n\t\t\t<th>File</th>";
  40. print "\n\t\t\t<th>Line</th>";
  41. print "\n\t\t\t<th>Call</th>";
  42. print "\n\t\t</tr>";
  43. print "\n\t</thead>";
  44. print "\n\t<tbody>";
  45. if (is_array($traceArray)) {
  46. foreach($traceArray as $i => $trace) {
  47. /* each $traceArray element represents a step in the call hiearchy. Print them from bottom up. */
  48. $file = basename($trace['file']);
  49. $line = $trace['line'];
  50. $function = $trace['function'];
  51. $class = isset($trace['class'])?$trace['class']:'';
  52. $type = isset($trace['type'])?$trace['type']:'';
  53. $args = ArgumentRenderer::renderManyArguments($trace['args'], false, false);
  54. print "\n\t\t<tr>";
  55. print "\n\t\t\t<td>$i</td>";
  56. print "\n\t\t\t<td title=\"".$trace['file']."\">$file</td>";
  57. print "\n\t\t\t<td>$line</td>";
  58. print "\n\t\t\t<td style='font-family: monospace; white-space: nowrap'>$class$type$function($args);</td>";
  59. print "\n\t\t</tr>";
  60. }
  61. }
  62. print "\n\t</tbody>";
  63. print "\n</table>";
  64. if ($return) return ob_get_clean();
  65. }
  66.  
  67. ?>

Documentation generated on Wed, 19 Sep 2007 10:27:22 -0400 by phpDocumentor 1.3.0RC3