mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +02:00
parent
b764993091
commit
9c5878cbbe
@ -206,10 +206,8 @@ class Manager
|
||||
{
|
||||
if (!$this->hasInstalled($name)) {
|
||||
throw new ConfigurationError(
|
||||
sprintf(
|
||||
'Cannot enable module "%s". Module is not installed.',
|
||||
$name
|
||||
)
|
||||
'Cannot enable module "%s". Module is not installed.',
|
||||
$name
|
||||
);
|
||||
}
|
||||
|
||||
@ -268,14 +266,18 @@ class Manager
|
||||
}
|
||||
$link = $this->enableDir . '/' . $name;
|
||||
if (!file_exists($link)) {
|
||||
throw new ConfigurationError('Could not disable module. The module ' . $name . ' was not found.');
|
||||
throw new ConfigurationError(
|
||||
'Could not disable module. The module %s was not found.',
|
||||
$name
|
||||
);
|
||||
}
|
||||
if (!is_link($link)) {
|
||||
throw new ConfigurationError(
|
||||
'Could not disable module. The module "' . $name . '" is not a symlink. '
|
||||
'Could not disable module. The module "%s" is not a symlink. '
|
||||
. 'It looks like you have installed this module manually and moved it to your module folder. '
|
||||
. 'In order to dynamically enable and disable modules, you have to create a symlink to '
|
||||
. 'the enabled_modules folder.'
|
||||
. 'the enabled_modules folder.',
|
||||
$name
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,9 @@ class AuthChain implements Iterator
|
||||
} catch (ConfigurationError $e) {
|
||||
Logger::error(
|
||||
new ConfigurationError(
|
||||
'Cannot create authentication backend "' . $name . '". An exception was thrown:', 0, $e
|
||||
'Cannot create authentication backend "%s". An exception was thrown:',
|
||||
$name,
|
||||
$e
|
||||
)
|
||||
);
|
||||
$this->next();
|
||||
|
@ -54,16 +54,18 @@ abstract class UserBackend implements Countable
|
||||
// Use a custom backend class, this is only useful for testing
|
||||
if (!class_exists($backendConfig->class)) {
|
||||
throw new ConfigurationError(
|
||||
'Authentication configuration for backend "' . $name . '" defines an invalid backend'
|
||||
. ' class. Backend class "' . $backendConfig->class. '" not found'
|
||||
'Authentication configuration for backend "%s" defines an invalid backend class.'
|
||||
. ' Backend class "%s" not found',
|
||||
$name,
|
||||
$backendConfig->class
|
||||
);
|
||||
}
|
||||
return new $backendConfig->class($backendConfig);
|
||||
}
|
||||
if (($backendType = $backendConfig->backend) === null) {
|
||||
throw new ConfigurationError(
|
||||
'Authentication configuration for backend "' . $name
|
||||
. '" is missing the backend directive'
|
||||
'Authentication configuration for backend "%s" is missing the backend directive',
|
||||
$name
|
||||
);
|
||||
}
|
||||
$backendType = strtolower($backendType);
|
||||
@ -74,8 +76,8 @@ abstract class UserBackend implements Countable
|
||||
}
|
||||
if ($backendConfig->resource === null) {
|
||||
throw new ConfigurationError(
|
||||
'Authentication configuration for backend "' . $name
|
||||
. '" is missing the resource directive'
|
||||
'Authentication configuration for backend "%s" is missing the resource directive',
|
||||
$name
|
||||
);
|
||||
}
|
||||
try {
|
||||
@ -100,22 +102,24 @@ abstract class UserBackend implements Countable
|
||||
case 'ldap':
|
||||
if (($userClass = $backendConfig->user_class) === null) {
|
||||
throw new ConfigurationError(
|
||||
'Authentication configuration for backend "' . $name
|
||||
. '" is missing the user_class directive'
|
||||
'Authentication configuration for backend "%s" is missing the user_class directive',
|
||||
$name
|
||||
);
|
||||
}
|
||||
if (($userNameAttribute = $backendConfig->user_name_attribute) === null) {
|
||||
throw new ConfigurationError(
|
||||
'Authentication configuration for backend "' . $name
|
||||
. '" is missing the user_name_attribute directive'
|
||||
'Authentication configuration for backend "%s" is missing the user_name_attribute directive',
|
||||
$name
|
||||
);
|
||||
}
|
||||
$backend = new LdapUserBackend($resource, $userClass, $userNameAttribute);
|
||||
break;
|
||||
default:
|
||||
throw new ConfigurationError(
|
||||
'Authentication configuration for backend "' . $name. '" defines an invalid backend'
|
||||
. ' type. Backend type "' . $backendType . '" is not supported'
|
||||
'Authentication configuration for backend "%s" defines an invalid backend type.'
|
||||
. ' Backend type "%s" is not supported',
|
||||
$name,
|
||||
$backendType
|
||||
);
|
||||
}
|
||||
$backend->setName($name);
|
||||
|
@ -142,7 +142,10 @@ class DbConnection implements Selectable
|
||||
}
|
||||
break;*/
|
||||
default:
|
||||
throw new ConfigurationError(sprintf('Backend "%s" is not supported', $this->dbType));
|
||||
throw new ConfigurationError(
|
||||
'Backend "%s" is not supported',
|
||||
$this->dbType
|
||||
);
|
||||
}
|
||||
$this->dbAdapter = Zend_Db::factory($adapter, $adapterParamaters);
|
||||
$this->dbAdapter->setFetchMode(Zend_Db::FETCH_OBJ);
|
||||
|
@ -39,7 +39,8 @@ class ResourceFactory implements ConfigAwareFactory
|
||||
self::assertResourcesExist();
|
||||
if (($resourceConfig = self::$resources->get($resourceName)) === null) {
|
||||
throw new ConfigurationError(
|
||||
'Cannot load resource config "' . $resourceName . '". Resource does not exist'
|
||||
'Cannot load resource config "%s". Resource does not exist',
|
||||
$resourceName
|
||||
);
|
||||
}
|
||||
return $resourceConfig;
|
||||
@ -113,7 +114,10 @@ class ResourceFactory implements ConfigAwareFactory
|
||||
$resource = new FileReader($config);
|
||||
break;
|
||||
default:
|
||||
throw new ConfigurationError('Unsupported resource type "' . $config->type . '"');
|
||||
throw new ConfigurationError(
|
||||
'Unsupported resource type "%s"',
|
||||
$config->type
|
||||
);
|
||||
}
|
||||
return $resource;
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ namespace Icinga\Exception;
|
||||
* Class ConfigurationError
|
||||
* @package Icinga\Exception
|
||||
*/
|
||||
class ConfigurationError extends \RuntimeException
|
||||
class ConfigurationError extends IcingaException
|
||||
{
|
||||
}
|
||||
|
@ -79,7 +79,10 @@ class Logger
|
||||
{
|
||||
$class = 'Icinga\\Logger\\Writer\\' . ucfirst(strtolower($config->type)) . 'Writer';
|
||||
if (!class_exists($class)) {
|
||||
throw new ConfigurationError('Cannot find log writer of type "' . $config->type . '"');
|
||||
throw new ConfigurationError(
|
||||
'Cannot find log writer of type "%s"',
|
||||
$config->type
|
||||
);
|
||||
}
|
||||
|
||||
return new $class($config);
|
||||
|
@ -33,13 +33,20 @@ class FileWriter extends LogWriter
|
||||
$this->path = $config->target;
|
||||
|
||||
if (substr($this->path, 0, 6) !== 'php://' && false === file_exists(dirname($this->path))) {
|
||||
throw new ConfigurationError('Log path "' . dirname($this->path) . '" does not exist');
|
||||
throw new ConfigurationError(
|
||||
'Log path "%s" does not exist',
|
||||
dirname($this->path)
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->write(''); // Avoid to handle such errors on every write access
|
||||
} catch (Exception $e) {
|
||||
throw new ConfigurationError('Cannot write to log file "' . $this->path . '" (' . $e->getMessage() . ')');
|
||||
throw new ConfigurationError(
|
||||
'Cannot write to log file "%s" (%s)',
|
||||
$this->path,
|
||||
$e->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,8 @@ class SyslogWriter extends LogWriter
|
||||
{
|
||||
if (!array_key_exists($config->facility, $this->facilities)) {
|
||||
throw new ConfigurationError(
|
||||
'Cannot create syslog writer with unknown facility "' . $config->facility . '"'
|
||||
'Cannot create syslog writer with unknown facility "%s"',
|
||||
$config->facility
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -49,11 +49,9 @@ class LocalPipe implements Transport
|
||||
$file->fflush();
|
||||
} catch (Exception $e) {
|
||||
throw new ConfigurationError(
|
||||
sprintf(
|
||||
'Could not open icinga command pipe at "%s" (%s)',
|
||||
$this->path,
|
||||
$e->getMessage()
|
||||
)
|
||||
'Could not open icinga command pipe at "%s" (%s)',
|
||||
$this->path,
|
||||
$e->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,8 @@ class Reader implements IReader, Selectable
|
||||
{
|
||||
if (!is_readable($this->config->object_file)) {
|
||||
throw new ConfigurationError(
|
||||
'Can\'t read object-file "' . $this->config->object_file . '", check your configuration'
|
||||
'Can\'t read object-file "%s", check your configuration',
|
||||
$this->config->object_file
|
||||
);
|
||||
}
|
||||
if (!$this->parser) {
|
||||
@ -265,7 +266,8 @@ class Reader implements IReader, Selectable
|
||||
{
|
||||
if (!is_readable($this->config->status_file)) {
|
||||
throw new ConfigurationError(
|
||||
"Can't read status-file {$this->config->status_file}, check your configuration"
|
||||
'Can\'t read status-file %s, check your configuration',
|
||||
$this->config->status_file
|
||||
);
|
||||
}
|
||||
if (!$this->parser) {
|
||||
|
@ -127,7 +127,8 @@ abstract class PreferencesStore
|
||||
$storeClass = 'Icinga\\User\\Preferences\\Store\\' . $type . 'Store';
|
||||
if (!class_exists($storeClass)) {
|
||||
throw new ConfigurationError(
|
||||
'Preferences configuration defines an invalid storage type. Storage type ' . $type . ' not found'
|
||||
'Preferences configuration defines an invalid storage type. Storage type %s not found',
|
||||
$type
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ class Pane extends AbstractWidget
|
||||
} elseif (is_string($component) && $url !== null) {
|
||||
$this->components[$component] = new Component($component, $url, $this);
|
||||
} else {
|
||||
throw new ConfigurationError('Invalid component added: ' . $component);
|
||||
throw new ConfigurationError('Invalid component added: %s', $component);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ class Monitoring_CommandController extends Controller
|
||||
if ($targetConfig->get($instance)) {
|
||||
$this->target = new CommandPipe($targetConfig->get($instance));
|
||||
} else {
|
||||
throw new ConfigurationError('Instance is not configured: '. $instance);
|
||||
throw new ConfigurationError('Instance is not configured: %s', $instance);
|
||||
}
|
||||
} else {
|
||||
if ($targetConfig && $targetInfo = $targetConfig->current()) {
|
||||
|
@ -87,12 +87,13 @@ class Backend implements Selectable, Queryable, ConnectionInterface
|
||||
$backendConfig = $defaultBackend;
|
||||
} else {
|
||||
if (!array_key_exists($backendName, $allBackends)) {
|
||||
throw new ConfigurationError('No configuration for backend ' . $backendName);
|
||||
throw new ConfigurationError('No configuration for backend %s', $backendName);
|
||||
}
|
||||
$backendConfig = $allBackends[$backendName];
|
||||
if ((bool) $backendConfig->get('disabled', false)) {
|
||||
throw new ConfigurationError(
|
||||
'Configuration for backend ' . $backendName . ' available but backend is disabled'
|
||||
'Configuration for backend %s available but backend is disabled',
|
||||
$backendName
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user