Upgrdae Inspection API again

Do not use InspectionException any more to reduce complexity of nested inspections, but keep error states
in the Inspection object itself.

refs #9630
This commit is contained in:
Matthias Jentsch 2015-07-15 18:36:19 +02:00
parent 6762ef053e
commit 276aa43aa2
2 changed files with 9 additions and 10 deletions

View File

@ -2,18 +2,19 @@
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ /* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
namespace Icinga\Data; namespace Icinga\Data;
use Icinga\Exception\InspectionException;
/** /**
* An object for which the user can retrieve status information * An object for which the user can retrieve status information
*
* This interface is useful for providing summaries or diagnostic information about objects
* to users.
*/ */
interface Inspectable interface Inspectable
{ {
/** /**
* Get information about this objects state * Inspect this object to gain extended information about its health
* *
* @return Inspection * @return Inspection The inspection result
* @throws InspectionException When inspection of the object was not possible
*/ */
public function inspect(); public function inspect();
} }

View File

@ -1088,11 +1088,9 @@ class LdapConnection implements Selectable, Inspectable
} }
/** /**
* Test if needed aspects of the LDAP connection are working as expected * Inspect if this LDAP Connection is working as expected
* *
* @return Inspection Information about the tested connection * @return Inspection Inspection result
*
* @throws InspectionException When inspection failed
*/ */
public function inspect() public function inspect()
{ {
@ -1102,7 +1100,7 @@ class LdapConnection implements Selectable, Inspectable
try { try {
$ds = $this->prepareNewConnection($insp); $ds = $this->prepareNewConnection($insp);
} catch (Exception $e) { } catch (Exception $e) {
throw new InspectionException($e->getMessage(), $insp); return $insp->error($e->getMessage());
} }
// Try a bind-command with the given user credentials, this must not fail // Try a bind-command with the given user credentials, this must not fail
@ -1115,7 +1113,7 @@ class LdapConnection implements Selectable, Inspectable
'***' /* $this->bindPw */ '***' /* $this->bindPw */
); );
if (! $success) { if (! $success) {
$insp->error(sprintf('%s failed: %s', $msg, ldap_error($ds))); return $insp->error(sprintf('%s failed: %s', $msg, ldap_error($ds)));
} }
$insp->write(sprintf($msg . ' successful')); $insp->write(sprintf($msg . ' successful'));