[xyphpexception commit] r22 - in trunk: . xyexception-includes xyexception-tests

0 views
Skip to first unread message

codesite...@google.com

unread,
Apr 13, 2007, 12:05:10 PM4/13/07
to xyphpexce...@googlegroups.com
Author: xhochy
Date: Fri Apr 13 09:04:52 2007
New Revision: 22

Modified:
trunk/.project
trunk/xyexception-includes/xyexception.exception.php
trunk/xyexception-tests/xyexception.test.php

Log:
Replaced own Trace management with the internal of PHP

Modified: trunk/.project
==============================================================================
--- trunk/.project (original)
+++ trunk/.project Fri Apr 13 09:04:52 2007
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>xyphpexception</name>
+ <name>XhochY PHP Exception</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
+ <nature>net.sourceforge.phpeclipse.phpnature</nature>
</natures>
</projectDescription>

Modified: trunk/xyexception-includes/xyexception.exception.php
==============================================================================
--- trunk/xyexception-includes/xyexception.exception.php (original)
+++ trunk/xyexception-includes/xyexception.exception.php Fri Apr 13 09:04:52 2007
@@ -21,16 +21,8 @@
{
parent::__construct($message, $code);

- $this->aTrace = array();
$this->aVars = array();
}
-
- /**
- * Der Stack des Programms bei Auftritt des Fehlers
- *
- * @var array
- */
- protected $aTrace;

/**
* Variablen, die vllt zur Behebung des Fehlers beitragen könnten
@@ -38,22 +30,6 @@
* @var array
*/
protected $aVars;
-
- /**
- * Fuegt eine Ebene der Exception hinzu
- * Excpetions sollten möglichst spät erst zum Schluss des Scripts fuehren
- *
- * @author Uwe L. Korn <uw...@xhochy.org>
- * @param string $sLine
- * @param string $sFile
- * @param string $sFunction
- * @param string $sClass
- */
- public function AddTrace($sFile, $sLine, $sFunction = '', $sClass = '')
- {
- $this->aTrace[] = array('File' => $sFile, 'Line' =>$sLine,
- 'Class' => $sClass, 'Function' => $sFunction);
- }

/**
* Fuegt eine Variable den Debug-Informationen hinzu
@@ -65,35 +41,13 @@
{
$this->aVars[$sKey] = $sValue;
}
-
- /**
- * Gibt aTrace als String aus
- *
- * @return string
- */
- public function TraceToString()
- {
- $sResult = '';
- for($i = 0; $i < count($this->aTrace); $i++)
- {
- $sResult.= "\t";
- $sResult.= $this->aTrace[$i]['File'].':';
- $sResult.= $this->aTrace[$i]['Line'].':';
- if($this->aTrace[$i]['Class'] != '')
- $sResult.= "\t".$this->aTrace[$i]['Class'].'::';
- if($this->aTrace[$i]['Function'] != '')
- $sResult.= $this->aTrace[$i]['Function'];
- $sResult.= "\n";
- }
- return $sResult;
- }

/**
* Gibt die Debug-Variabeln aus
*
* @return string
*/
- public function VarsToString()
+ public function getVarsAsString()
{
$sResult = '';
foreach($this->aVars as $sKey=>$sValue)
@@ -143,8 +97,9 @@
*/
public function getMailSubject()
{
- return __CLASS__.' in file '.$this->aTrace[0]['File']
- .' at line '.$this->aTrace[0]['Line'];
+ $aTrace = $this->getTrace();
+ return __CLASS__.' in file '.$aTrace[1]['file']
+ .' at line '.$aTrace[1]['line'];
}

/**
@@ -156,12 +111,13 @@
*/
public function getMailBody()
{
- $sResult = __CLASS__.' in file '.$this->aTrace[0]['File']
- .' at line '.$this->aTrace[0]['Line']."\n";
+ $aTrace = $this->getTrace();
+ $sResult = __CLASS__.' in file '.$aTrace[1]['file']
+ .' at line '.$aTrace[1]['line']."\n";
$sResult.= "\nTrace:\n";
- $sResult.= $this->TraceToString();
+ $sResult.= $this->getTraceAsString();
$sResult.= "\nVars:\n";
- $sResult.= $this->VarsToString();
+ $sResult.= $this->getVarsAsString();
return $sResult;
}
}

Modified: trunk/xyexception-tests/xyexception.test.php
==============================================================================
--- trunk/xyexception-tests/xyexception.test.php (original)
+++ trunk/xyexception-tests/xyexception.test.php Fri Apr 13 09:04:52 2007
@@ -43,26 +43,15 @@
{
$oException = new XYException('testerror',0);
$oException->addVar('s','t');
- $sVars = $oException->VarsToString();
+ $sVars = $oException->getVarsAsString();
if(empty($sVars)) {
$this->fail();
}
}

- public function testAddTrace()
- {
- $oException = new XYException('testerror',0);
- $oException->addTrace(__FILE__, __LINE__, __FUNCTION__, __CLASS__);
- $sTrace = $oException->TraceToString();
- if(empty($sTrace)) {
- $this->fail();
- }
- }
-
public function testgetMailSubject_Basic()
{
$oException = new XYException('testerror',0);
- $oException->addTrace(__FILE__, __LINE__, __FUNCTION__, __CLASS__);
$sMailSubject = $oException->getMailSubject();
if (empty($sMailSubject)) {
$this->fail();
@@ -72,7 +61,6 @@
public function testgetMailBody_Basic()
{
$oException = new XYException('testerror',0);
- $oException->addTrace(__FILE__, __LINE__, __FUNCTION__, __CLASS__);
$sMailBody = $oException->getMailBody();
if (empty($sMailBody)) {
$this->fail();

Reply all
Reply to author
Forward
0 new messages