From 2c8235d4869e99e458732989b9f3f2c4e8a0547f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 27 Jul 2015 16:25:41 +0200 Subject: [PATCH] lib: Introduce IcingaException::create() refs #9644 --- library/Icinga/Exception/IcingaException.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/Icinga/Exception/IcingaException.php b/library/Icinga/Exception/IcingaException.php index ab6591b01..62c7942be 100644 --- a/library/Icinga/Exception/IcingaException.php +++ b/library/Icinga/Exception/IcingaException.php @@ -4,6 +4,7 @@ namespace Icinga\Exception; use Exception; +use ReflectionClass; class IcingaException extends Exception { @@ -25,4 +26,17 @@ class IcingaException extends Exception } parent::__construct(vsprintf($message, $args), 0, $exc); } + + /** + * Create the exception from an array of arguments + * + * @param array $args + * + * @return static + */ + public static function create(array $args) + { + $e = new ReflectionClass(get_called_class()); + return $e->newInstanceArgs($args); + } }