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:
parent
6762ef053e
commit
276aa43aa2
|
@ -2,18 +2,19 @@
|
|||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Data;
|
||||
use Icinga\Exception\InspectionException;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
/**
|
||||
* Get information about this objects state
|
||||
* Inspect this object to gain extended information about its health
|
||||
*
|
||||
* @return Inspection
|
||||
* @throws InspectionException When inspection of the object was not possible
|
||||
* @return Inspection The inspection result
|
||||
*/
|
||||
public function inspect();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*
|
||||
* @throws InspectionException When inspection failed
|
||||
* @return Inspection Inspection result
|
||||
*/
|
||||
public function inspect()
|
||||
{
|
||||
|
@ -1102,7 +1100,7 @@ class LdapConnection implements Selectable, Inspectable
|
|||
try {
|
||||
$ds = $this->prepareNewConnection($insp);
|
||||
} 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
|
||||
|
@ -1115,7 +1113,7 @@ class LdapConnection implements Selectable, Inspectable
|
|||
'***' /* $this->bindPw */
|
||||
);
|
||||
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'));
|
||||
|
||||
|
|
Loading…
Reference in New Issue