File: Pear.php

package info (click to toggle)
php-horde-ingo 3.2.16-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 5,428 kB
  • sloc: php: 9,583; xml: 4,072; javascript: 184; makefile: 19; sh: 3
file content (40 lines) | stat: -rw-r--r-- 1,105 bytes parent folder | download | duplicates (3)
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
<?php
/**
 * Copyright 2011-2017 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (ASL).  If you
 * did not receive this file, see http://www.horde.org/licenses/apache.
 *
 * @author   Jan Schneider <jan@horde.org>
 * @category Horde
 * @license  http://www.horde.org/licenses/apache ASL
 * @package  Ingo
 */

/**
 * Ingo exception class that converts PEAR errors to exceptions.
 *
 * @author   Jan Schneider <jan@horde.org>
 * @category Horde
 * @license  http://www.horde.org/licenses/apache ASL
 * @package  Ingo
 */
class Ingo_Exception_Pear extends Horde_Exception_Pear
{
    /**
     * Exception handling.
     *
     * @param mixed $result The result to be checked for a PEAR_Error.
     *
     * @return mixed Returns the original result if it was no PEAR_Error.
     *
     * @throws Ingo_Exception In case the result was a PEAR_Error.
     */
    static public function catchError($result)
    {
        if ($result instanceof PEAR_Error) {
            throw new Ingo_Exception(new self::$_class($result));
        }
        return $result;
    }
}