1: <?php
2: /**
3: * Horde exception class that accepts output of error_get_last() as $code and
4: * mask itself as that error.
5: *
6: * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (LGPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
10: *
11: * @category Horde
12: * @package Exception
13: */
14: class Horde_Exception_LastError extends Horde_Exception
15: {
16: /**
17: * Exception constructor
18: *
19: * If $lasterror is passed the return value of error_get_last() (or a
20: * matching format), the exception will be rewritten to have its file and
21: * line parameters match that of the array, and any message in the array
22: * will be appended to $message.
23: *
24: * @param mixed $message The exception message, a PEAR_Error
25: * object, or an Exception object.
26: * @param mixed $code_or_lasterror Either a numeric error code, or
27: * an array from error_get_last().
28: */
29: public function __construct($message = null, $code_or_lasterror = null)
30: {
31: if (is_array($code_or_lasterror)) {
32: if ($message) {
33: $message .= $code_or_lasterror['message'];
34: } else {
35: $message = $code_or_lasterror['message'];
36: }
37: parent::__construct($message, $code_or_lasterror['type']);
38: $this->file = $code_or_lasterror['file'];
39: $this->line = $code_or_lasterror['line'];
40: } else {
41: parent::__construct($message, $code_or_lasterror);
42: }
43: }
44:
45: }
46: