1: <?php
2: /**
3: * Ingo exception class that converts PEAR errors to exceptions.
4: *
5: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
6: *
7: * See the enclosed file LICENSE for license information (ASL). If you
8: * did not receive this file, see http://www.horde.org/licenses/apache.
9: *
10: * @author Jan Schneider <jan@horde.org>
11: * @package Ingo
12: */
13: class Ingo_Exception_Pear extends Horde_Exception_Pear
14: {
15: /**
16: * Exception handling.
17: *
18: * @param mixed $result The result to be checked for a PEAR_Error.
19: *
20: * @return mixed Returns the original result if it was no PEAR_Error.
21: *
22: * @throws Ingo_Exception In case the result was a PEAR_Error.
23: */
24: static public function catchError($result)
25: {
26: if ($result instanceof PEAR_Error) {
27: throw new Ingo_Exception(new self::$_class($result));
28: }
29: return $result;
30: }
31: }
32: