File: LastError.php

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

}