coreexception.class.inc.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. class CoreException extends Exception
  3. {
  4. public function __construct($sIssue, $aContextData = null, $sImpact = '')
  5. {
  6. $this->m_sIssue = $sIssue;
  7. $this->m_sImpact = $sImpact;
  8. $this->m_aContextData = $aContextData ? $aContextData : array();
  9. $sMessage = $sIssue;
  10. if (!empty($sImpact)) $sMessage .= "($sImpact)";
  11. if (count($this->m_aContextData) > 0)
  12. {
  13. $sMessage .= ": ";
  14. $aContextItems = array();
  15. foreach($this->m_aContextData as $sKey => $value)
  16. {
  17. if (is_array($value))
  18. {
  19. $aPairs = array();
  20. foreach($value as $key => $val)
  21. {
  22. if (is_array($val))
  23. {
  24. $aPairs[$key] = '('.implode(', ', $val).')';
  25. }
  26. else
  27. {
  28. $aPairs[$key] = $val;
  29. }
  30. }
  31. $sValue = '{'.implode('; ', $aPairs).'}';
  32. }
  33. else
  34. {
  35. $sValue = $value;
  36. }
  37. $aContextItems[] = "$sKey = $sValue";
  38. }
  39. $sMessage .= implode(', ', $aContextItems);
  40. }
  41. parent::__construct($sMessage, 0);
  42. }
  43. public function getHtmlDesc($sHighlightHtmlBegin = '<b>', $sHighlightHtmlEnd = '</b>')
  44. {
  45. return $this->getMessage();
  46. }
  47. public function getTraceAsHtml()
  48. {
  49. $aBackTrace = $this->getTrace();
  50. return MyHelpers::get_callstack_html(0, $this->getTrace());
  51. // return "<pre>\n".$this->getTraceAsString()."</pre>\n";
  52. }
  53. }
  54. class CoreWarning extends CoreException
  55. {
  56. }
  57. ?>