Subversion Repositories Applications.gtt

Rev

Rev 94 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 187
Line 3... Line 3...
3
/**
3
/**
4
 * PEAR_Exception
4
 * PEAR_Exception
5
 *
5
 *
6
 * PHP versions 4 and 5
6
 * PHP versions 4 and 5
7
 *
7
 *
8
 * LICENSE: This source file is subject to version 3.0 of the PHP license
-
 
9
 * that is available through the world-wide-web at the following URI:
-
 
10
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
-
 
11
 * the PHP License and are unable to obtain it through the web, please
-
 
12
 * send a note to license@php.net so we can mail you a copy immediately.
-
 
13
 *
-
 
14
 * @category   pear
8
 * @category   pear
15
 * @package    PEAR
9
 * @package    PEAR
16
 * @author     Tomas V. V. Cox <cox@idecnet.com>
10
 * @author     Tomas V. V. Cox <cox@idecnet.com>
17
 * @author     Hans Lellelid <hans@velum.net>
11
 * @author     Hans Lellelid <hans@velum.net>
18
 * @author     Bertrand Mansion <bmansion@mamasam.com>
12
 * @author     Bertrand Mansion <bmansion@mamasam.com>
19
 * @author     Greg Beaver <cellog@php.net>
13
 * @author     Greg Beaver <cellog@php.net>
20
 * @copyright  1997-2006 The PHP Group
14
 * @copyright  1997-2009 The Authors
21
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
15
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
22
 * @version    CVS: $Id: Exception.php,v 1.26 2006/10/30 03:47:48 cellog Exp $
-
 
23
 * @link       http://pear.php.net/package/PEAR
16
 * @link       http://pear.php.net/package/PEAR
24
 * @since      File available since Release 1.3.3
17
 * @since      File available since Release 1.3.3
25
 */
18
 */
Line 91... Line 84...
91
 * @package    PEAR
84
 * @package    PEAR
92
 * @author     Tomas V.V.Cox <cox@idecnet.com>
85
 * @author     Tomas V.V.Cox <cox@idecnet.com>
93
 * @author     Hans Lellelid <hans@velum.net>
86
 * @author     Hans Lellelid <hans@velum.net>
94
 * @author     Bertrand Mansion <bmansion@mamasam.com>
87
 * @author     Bertrand Mansion <bmansion@mamasam.com>
95
 * @author     Greg Beaver <cellog@php.net>
88
 * @author     Greg Beaver <cellog@php.net>
96
 * @copyright  1997-2006 The PHP Group
89
 * @copyright  1997-2009 The Authors
97
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
90
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
98
 * @version    Release: 1.5.1
91
 * @version    Release: 1.10.1
99
 * @link       http://pear.php.net/package/PEAR
92
 * @link       http://pear.php.net/package/PEAR
100
 * @since      Class available since Release 1.3.3
93
 * @since      Class available since Release 1.3.3
101
 *
94
 *
102
 */
95
 */
103
class PEAR_Exception extends Exception
96
class PEAR_Exception extends Exception
Line 258... Line 251...
258
                              'message' => $this->cause->getMessage(),
251
                              'message' => $this->cause->getMessage(),
259
                              'file' => $this->cause->getFile(),
252
                              'file' => $this->cause->getFile(),
260
                              'line' => $this->cause->getLine());
253
                              'line' => $this->cause->getLine());
261
        } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) {
254
        } elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) {
262
            $causes[] = array('class' => get_class($this->cause),
255
            $causes[] = array('class' => get_class($this->cause),
263
                              'message' => $this->cause->getMessage());
256
                              'message' => $this->cause->getMessage(),
-
 
257
                              'file' => 'unknown',
-
 
258
                              'line' => 'unknown');
264
        } elseif (is_array($this->cause)) {
259
        } elseif (is_array($this->cause)) {
265
            foreach ($this->cause as $cause) {
260
            foreach ($this->cause as $cause) {
266
                if ($cause instanceof PEAR_Exception) {
261
                if ($cause instanceof PEAR_Exception) {
267
                    $cause->getCauseMessage($causes);
262
                    $cause->getCauseMessage($causes);
268
                } elseif ($cause instanceof Exception) {
263
                } elseif ($cause instanceof Exception) {
Line 270... Line 265...
270
                                   'message' => $cause->getMessage(),
265
                                   'message' => $cause->getMessage(),
271
                                   'file' => $cause->getFile(),
266
                                   'file' => $cause->getFile(),
272
                                   'line' => $cause->getLine());
267
                                   'line' => $cause->getLine());
273
                } elseif (class_exists('PEAR_Error') && $cause instanceof PEAR_Error) {
268
                } elseif (class_exists('PEAR_Error') && $cause instanceof PEAR_Error) {
274
                    $causes[] = array('class' => get_class($cause),
269
                    $causes[] = array('class' => get_class($cause),
275
                                      'message' => $cause->getMessage());
270
                                      'message' => $cause->getMessage(),
-
 
271
                                      'file' => 'unknown',
-
 
272
                                      'line' => 'unknown');
276
                } elseif (is_array($cause) && isset($cause['message'])) {
273
                } elseif (is_array($cause) && isset($cause['message'])) {
277
                    // PEAR_ErrorStack warning
274
                    // PEAR_ErrorStack warning
278
                    $causes[] = array(
275
                    $causes[] = array(
279
                        'class' => $cause['package'],
276
                        'class' => $cause['package'],
280
                        'message' => $cause['message'],
277
                        'message' => $cause['message'],
Line 289... Line 286...
289
            }
286
            }
290
        }
287
        }
291
    }
288
    }
Line 292... Line 289...
292
 
289
 
293
    public function getTraceSafe()
290
    public function getTraceSafe()
294
    {   
291
    {
295
        if (!isset($this->_trace)) {
292
        if (!isset($this->_trace)) {
296
            $this->_trace = $this->getTrace();
293
            $this->_trace = $this->getTrace();
297
            if (empty($this->_trace)) {
294
            if (empty($this->_trace)) {
298
                $backtrace = debug_backtrace();
295
                $backtrace = debug_backtrace();
Line 325... Line 322...
325
    public function toHtml()
322
    public function toHtml()
326
    {
323
    {
327
        $trace = $this->getTraceSafe();
324
        $trace = $this->getTraceSafe();
328
        $causes = array();
325
        $causes = array();
329
        $this->getCauseMessage($causes);
326
        $this->getCauseMessage($causes);
330
        $html =  '<table border="1" cellspacing="0">' . "\n";
327
        $html =  '<table style="border: 1px" cellspacing="0">' . "\n";
331
        foreach ($causes as $i => $cause) {
328
        foreach ($causes as $i => $cause) {
332
            $html .= '<tr><td colspan="3" bgcolor="#ff9999">'
329
            $html .= '<tr><td colspan="3" style="background: #ff9999">'
333
               . str_repeat('-', $i) . ' <b>' . $cause['class'] . '</b>: '
330
               . str_repeat('-', $i) . ' <b>' . $cause['class'] . '</b>: '
334
               . htmlspecialchars($cause['message']) . ' in <b>' . $cause['file'] . '</b> '
331
               . htmlspecialchars($cause['message']) . ' in <b>' . $cause['file'] . '</b> '
335
               . 'on line <b>' . $cause['line'] . '</b>'
332
               . 'on line <b>' . $cause['line'] . '</b>'
336
               . "</td></tr>\n";
333
               . "</td></tr>\n";
337
        }
334
        }
338
        $html .= '<tr><td colspan="3" bgcolor="#aaaaaa" align="center"><b>Exception trace</b></td></tr>' . "\n"
335
        $html .= '<tr><td colspan="3" style="background-color: #aaaaaa; text-align: center; font-weight: bold;">Exception trace</td></tr>' . "\n"
339
               . '<tr><td align="center" bgcolor="#cccccc" width="20"><b>#</b></td>'
336
               . '<tr><td style="text-align: center; background: #cccccc; width:20px; font-weight: bold;">#</td>'
340
               . '<td align="center" bgcolor="#cccccc"><b>Function</b></td>'
337
               . '<td style="text-align: center; background: #cccccc; font-weight: bold;">Function</td>'
341
               . '<td align="center" bgcolor="#cccccc"><b>Location</b></td></tr>' . "\n";
338
               . '<td style="text-align: center; background: #cccccc; font-weight: bold;">Location</td></tr>' . "\n";
Line 342... Line 339...
342
 
339
 
343
        foreach ($trace as $k => $v) {
340
        foreach ($trace as $k => $v) {
344
            $html .= '<tr><td align="center">' . $k . '</td>'
341
            $html .= '<tr><td style="text-align: center;">' . $k . '</td>'
345
                   . '<td>';
342
                   . '<td>';
346
            if (!empty($v['class'])) {
343
            if (!empty($v['class'])) {
347
                $html .= $v['class'] . $v['type'];
344
                $html .= $v['class'] . $v['type'];
348
            }
345
            }
Line 367... Line 364...
367
                   . '</td>'
364
                   . '</td>'
368
                   . '<td>' . (isset($v['file']) ? $v['file'] : 'unknown')
365
                   . '<td>' . (isset($v['file']) ? $v['file'] : 'unknown')
369
                   . ':' . (isset($v['line']) ? $v['line'] : 'unknown')
366
                   . ':' . (isset($v['line']) ? $v['line'] : 'unknown')
370
                   . '</td></tr>' . "\n";
367
                   . '</td></tr>' . "\n";
371
        }
368
        }
372
        $html .= '<tr><td align="center">' . ($k+1) . '</td>'
369
        $html .= '<tr><td style="text-align: center;">' . ($k+1) . '</td>'
373
               . '<td>{main}</td>'
370
               . '<td>{main}</td>'
374
               . '<td>&nbsp;</td></tr>' . "\n"
371
               . '<td>&nbsp;</td></tr>' . "\n"
375
               . '</table>';
372
               . '</table>';
376
        return $html;
373
        return $html;
377
    }
374
    }
Line 386... Line 383...
386
                   . $cause['message'] . ' in ' . $cause['file']
383
                   . $cause['message'] . ' in ' . $cause['file']
387
                   . ' on line ' . $cause['line'] . "\n";
384
                   . ' on line ' . $cause['line'] . "\n";
388
        }
385
        }
389
        return $causeMsg . $this->getTraceAsString();
386
        return $causeMsg . $this->getTraceAsString();
390
    }
387
    }
391
}
-
 
392
 
-
 
393
?>
-
 
394
388
}
-
 
389
395
390