/
Pear.php
40 lines (39 loc) · 1.08 KB
/
Pear.php
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;
}
}