Merge branch 'bugfix/exceptions-with-printf-params-6931'

fixes 
This commit is contained in:
Alexander Klimov 2014-08-26 11:25:51 +02:00
commit aec66570d6
46 changed files with 263 additions and 185 deletions

@ -61,7 +61,10 @@ class Config extends Zend_Config
$this->configFile = $filepath;
$this->merge(new Zend_Config_Ini($filepath));
} else {
throw new NotReadableError('Cannot read config file "' . $filename . '". Permission denied');
throw new NotReadableError(
'Cannot read config file "%s". Permission denied',
$filename
);
}
}

@ -39,11 +39,11 @@ class Loader
public function registerNamespace($namespace, $directory)
{
if (!is_dir($directory)) {
throw new ProgrammingError(sprintf(
throw new ProgrammingError(
'Directory "%s" for namespace "%s" does not exist',
$directory,
$namespace
));
);
}
$this->namespaces[$namespace] = $directory;

@ -110,12 +110,14 @@ class Manager
}
if (!is_dir($this->enableDir)) {
throw new NotReadableError(
'Cannot read enabled modules. Module directory "' . $this->enableDir . '" is not a directory'
'Cannot read enabled modules. Module directory "%s" is not a directory',
$this->enableDir
);
}
if (!is_readable($this->enableDir)) {
throw new NotReadableError(
'Cannot read enabled modules. Module directory "' . $this->enableDir . '" is not readable'
'Cannot read enabled modules. Module directory "%s" is not readable',
$this->enableDir
);
}
if (($dh = opendir($canonical)) !== false) {
@ -206,10 +208,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
);
}
@ -219,8 +219,8 @@ class Manager
if (!is_writable($this->enableDir)) {
throw new SystemPermissionException(
'Can not enable module "' . $name . '". '
. 'Insufficient system permissions for enabling modules.'
'Can not enable module "%s". Insufficient system permissions for enabling modules.',
$name
);
}
@ -232,9 +232,11 @@ class Manager
$error = error_get_last();
if (strstr($error["message"], "File exists") === false) {
throw new SystemPermissionException(
'Could not enable module "' . $name . '" due to file system errors. '
'Could not enable module "%s" due to file system errors. '
. 'Please check path and mounting points because this is not a permission error. '
. 'Primary error was: ' . $error['message']
. 'Primary error was: %s',
$name,
$error['message']
);
}
}
@ -268,14 +270,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
);
}
@ -283,9 +289,11 @@ class Manager
if (!@unlink($link)) {
$error = error_get_last();
throw new SystemPermissionException(
'Could not disable module "' . $name . '" due to file system errors. '
'Could not disable module "%s" due to file system errors. '
. 'Please check path and mounting points because this is not a permission error. '
. 'Primary error was: ' . $error['message']
. 'Primary error was: %s',
$name,
$error['message']
);
}
}
@ -319,10 +327,8 @@ class Manager
}
throw new ProgrammingError(
sprintf(
'Trying to access uninstalled module dir: %s',
$name
)
'Trying to access uninstalled module dir: %s',
$name
);
}
@ -388,10 +394,8 @@ class Manager
{
if (!$this->hasLoaded($name)) {
throw new ProgrammingError(
sprintf(
'Cannot access module %s as it hasn\'t been loaded',
$name
)
'Cannot access module %s as it hasn\'t been loaded',
$name
);
}
return $this->loadedModules[$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();

@ -73,12 +73,9 @@ class DbUserBackend extends UserBackend
return ($row !== false) ? true : false;
} catch (Exception $e) {
throw new AuthenticationException(
sprintf(
'Failed to authenticate user "%s" against backend "%s". An exception was thrown:',
$user->getUsername(),
$this->getName()
),
0,
'Failed to authenticate user "%s" against backend "%s". An exception was thrown:',
$user->getUsername(),
$this->getName(),
$e
);
}
@ -125,4 +122,4 @@ class DbUserBackend extends UserBackend
return ($row !== false) ? $row->count : 0;
}
}
}

@ -68,21 +68,17 @@ class LdapUserBackend extends UserBackend
$result = $q->fetchRow();
if (! isset($result)) {
throw new AuthenticationException(
sprintf(
'No objects with objectClass="%s" in DN="%s" found.',
$this->userClass,
$this->conn->getDN()
)
'No objects with objectClass="%s" in DN="%s" found.',
$this->userClass,
$this->conn->getDN()
);
}
if (! isset($result->{$this->userNameAttribute})) {
throw new AuthenticationException(
sprintf(
'UserNameAttribute "%s" not existing in objectClass="%s"',
$this->userNameAttribute,
$this->userClass
)
'UserNameAttribute "%s" not existing in objectClass="%s"',
$this->userNameAttribute,
$this->userClass
);
}
}
@ -121,11 +117,8 @@ class LdapUserBackend extends UserBackend
} catch (AuthenticationException $e) {
// Authentication not possible
throw new AuthenticationException(
sprintf(
'Authentication against backend "%s" not possible: ',
$this->getName()
),
0,
'Authentication against backend "%s" not possible: ',
$this->getName(),
$e
);
}
@ -141,12 +134,9 @@ class LdapUserBackend extends UserBackend
} catch (LdapException $e) {
// Error during authentication of this specific user
throw new AuthenticationException(
sprintf(
'Failed to authenticate user "%s" against backend "%s". An exception was thrown:',
$user->getUsername(),
$this->getName()
),
0,
'Failed to authenticate user "%s" against backend "%s". An exception was thrown:',
$user->getUsername(),
$this->getName(),
$e
);
}

@ -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);

@ -332,7 +332,8 @@ class Loader
{
if (! $this->hasModule($module)) {
throw new ProgrammingError(
sprintf('There is no such module: %s', $module)
'There is no such module: %s',
$module
);
}
}
@ -341,7 +342,8 @@ class Loader
{
if (! $this->hasCommand($command)) {
throw new ProgrammingError(
sprintf('There is no such command: %s', $command)
'There is no such command: %s',
$command
);
}
}
@ -351,7 +353,9 @@ class Loader
$this->assertModuleExists($module);
if (! $this->hasModuleCommand($module, $command)) {
throw new ProgrammingError(
sprintf("The module '%s' has no such command: %s", $module, $command)
'The module \'%s\' has no such command: %s',
$module,
$command
);
}
}

@ -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);

@ -34,9 +34,12 @@ abstract class Filter
if ((string) $id === $this->getId()) {
return $this;
}
throw new ProgrammingError(sprintf(
'Trying to get invalid filter index "%s" from "%s" ("%s")', $id, $this, $this->id
));
throw new ProgrammingError(
'Trying to get invalid filter index "%s" from "%s" ("%s")',
$id,
$this,
$this->id
);
}
public function getId()
@ -136,7 +139,8 @@ abstract class Filter
case '<=': return new FilterEqualOrLessThan($col, $op, $expression);
case '!=': return new FilterNotEqual($col, $op, $expression);
default: throw new ProgrammingError(
sprintf('There is no such filter sign: %s', $op)
'There is no such filter sign: %s',
$op
);
}
}
@ -188,7 +192,7 @@ abstract class Filter
$args = $args[0];
}
}
if (count($args) > 1) {
if (count($args) > 1) {
return new FilterNot(array(new FilterAnd($args)));
} else {
return new FilterNot($args);
@ -203,7 +207,8 @@ abstract class Filter
case 'NOT': return self::not($filters);
}
throw new ProgrammingError(
sprintf('"%s" is not a valid filter chain operator', $operator)
'"%s" is not a valid filter chain operator',
$operator
);
}

@ -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;
@ -77,7 +78,7 @@ class ResourceFactory implements ConfigAwareFactory
{
if (!isset(self::$resources)) {
throw new ProgrammingError(
"The ResourceFactory must be initialised by setting a config, before it can be used"
'The ResourceFactory must be initialised by setting a config, before it can be used'
);
}
}
@ -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;
}

@ -4,11 +4,9 @@
namespace Icinga\Exception;
use RuntimeException;
/**
* Exception thrown if an error occurs during authentication
*/
class AuthenticationException extends RuntimeException
class AuthenticationException extends IcingaException
{
}

@ -8,6 +8,6 @@ namespace Icinga\Exception;
* Class ConfigurationError
* @package Icinga\Exception
*/
class ConfigurationError extends \RuntimeException
class ConfigurationError extends IcingaException
{
}

@ -0,0 +1,29 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Exception;
use Exception;
class IcingaException extends Exception
{
/**
* @param string $message format string for vsprintf()
* Any futher args: args for vsprintf()
* @see vsprintf
*
* If there is at least one exception, the last one will be also used for the exception chaining.
*/
public function __construct($message = '')
{
$args = array_slice(func_get_args(), 1);
$exc = null;
foreach ($args as &$arg) {
if ($arg instanceof Exception) {
$exc = $arg;
}
}
parent::__construct(vsprintf($message, $args), 0, $exc);
}
}

@ -4,12 +4,10 @@
namespace Icinga\Exception;
use RuntimeException;
/**
* Class MissingParameterException
* @package Icinga\Exception
*/
class MissingParameterException extends RuntimeException
class MissingParameterException extends IcingaException
{
}

@ -8,6 +8,6 @@ namespace Icinga\Exception;
* Class NotImplementedError
* @package Icinga\Exception
*/
class NotImplementedError extends \Exception
class NotImplementedError extends IcingaException
{
}

@ -4,8 +4,6 @@
namespace Icinga\Exception;
use RuntimeException;
class NotReadableError extends RuntimeException
class NotReadableError extends IcingaException
{
}

@ -4,8 +4,6 @@
namespace Icinga\Exception;
use RuntimeException;
class NotWritableError extends RuntimeException
class NotWritableError extends IcingaException
{
}

@ -8,6 +8,6 @@ namespace Icinga\Exception;
* Class ProgrammingError
* @package Icinga\Exception
*/
class ProgrammingError extends \Exception
class ProgrammingError extends IcingaException
{
}

@ -4,11 +4,9 @@
namespace Icinga\Exception;
use \Exception;
/**
* Handle problems according to file system permissions
*/
class SystemPermissionException extends Exception
class SystemPermissionException 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
);
}

@ -138,7 +138,10 @@ abstract class Command
*/
public function getHostgroupCommand($hostgroup)
{
throw new ProgrammingError(get_class($this) . ' does not provide a hostgroup command');
throw new ProgrammingError(
'%s does not provide a hostgroup command',
get_class($this)
);
}
/**
@ -150,7 +153,10 @@ abstract class Command
*/
public function getServicegroupCommand($servicegroup)
{
throw new ProgrammingError(get_class($this) . ' does not provide a servicegroup command');
throw new ProgrammingError(
'%s does not provide a servicegroup command',
get_class($this)
);
}
/**
@ -163,6 +169,9 @@ abstract class Command
*/
public function getGlobalCommand($instance = null)
{
throw new ProgrammingError(getclass($this) . ' does not provide a global command');
throw new ProgrammingError(
'%s does not provide a global command',
getclass($this)
);
}
}

@ -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
);
}

@ -78,7 +78,9 @@ class DbStore extends PreferencesStore
->fetchAll();
} catch (Exception $e) {
throw new NotReadableError(
'Cannot fetch preferences for user ' . $this->getUser()->getUsername() . ' from database', 0, $e
'Cannot fetch preferences for user %s from database',
$this->getUser()->getUsername(),
$e
);
}
@ -145,7 +147,9 @@ class DbStore extends PreferencesStore
}
} catch (Exception $e) {
throw new NotWritableError(
'Cannot insert preferences for user ' . $this->getUser()->getUsername() . ' into database', 0, $e
'Cannot insert preferences for user %s into database',
$this->getUser()->getUsername(),
$e
);
}
}
@ -174,7 +178,9 @@ class DbStore extends PreferencesStore
}
} catch (Exception $e) {
throw new NotWritableError(
'Cannot update preferences for user ' . $this->getUser()->getUsername() . ' in database', 0, $e
'Cannot update preferences for user %s in database',
$this->getUser()->getUsername(),
$e
);
}
}
@ -200,7 +206,9 @@ class DbStore extends PreferencesStore
);
} catch (Exception $e) {
throw new NotWritableError(
'Cannot delete preferences for user ' . $this->getUser()->getUsername() . ' from database', 0, $e
'Cannot delete preferences for user %s from database',
$this->getUser()->getUsername(),
$e
);
}
}

@ -62,8 +62,9 @@ class IniStore extends PreferencesStore
if (file_exists($this->preferencesFile)) {
if (!is_readable($this->preferencesFile)) {
throw new NotReadableError(
'Preferences INI file ' . $this->preferencesFile . ' for user '
. $this->getUser()->getUsername() . ' is not readable'
'Preferences INI file %s for user %s is not readable',
$this->preferencesFile,
$this->getUser()->getUsername()
);
} else {
$this->preferences = parse_ini_file($this->preferencesFile);
@ -97,10 +98,8 @@ class IniStore extends PreferencesStore
if (!file_exists($this->preferencesFile)) {
if (!is_writable($this->getStoreConfig()->location)) {
throw new NotWritableError(
sprintf(
'Path to the preferences INI files %s is not writable',
$this->getStoreConfig()->location
)
'Path to the preferences INI files %s is not writable',
$this->getStoreConfig()->location
);
}
@ -109,8 +108,9 @@ class IniStore extends PreferencesStore
if (!is_writable($this->preferencesFile)) {
throw new NotWritableError(
'Preferences INI file ' . $this->preferencesFile . ' for user '
. $this->getUser()->getUsername() . ' is not writable'
'Preferences INI file %s for user %s is not writable',
$this->preferencesFile,
$this->getUser()->getUsername()
);
}

@ -95,7 +95,10 @@ class Format
return '-';
}
if (! preg_match('~^\d+$~', $timestamp)) {
throw new ProgrammingError(sprintf('"%s" is not a number', $timestamp));
throw new ProgrammingError(
'"%s" is not a number',
$timestamp
);
}
$prefix = '';
if ($diff < 0) {

@ -369,8 +369,8 @@ class Form extends Zend_Form
$element->setAttrib('class', $class);
} else {
throw new ProgrammingError(
'You need to add the element "' . $elementName . '" to' .
' the form before automatic submission can be enabled!'
'You need to add the element "%s" to the form before automatic submission can be enabled!',
$elementName
);
}
}

@ -117,11 +117,9 @@ class Hook
$base_class = self::$BASE_NS . ucfirst($name);
if (!$instance instanceof $base_class) {
throw new ProgrammingError(
sprintf(
'%s is not an instance of %s',
get_class($instance),
$base_class
)
'%s is not an instance of %s',
get_class($instance),
$base_class
);
}
}
@ -185,7 +183,10 @@ class Hook
public static function registerClass($name, $key, $class)
{
if (!class_exists($class)) {
throw new ProgrammingError('"' . $class . '" is not an existing class');
throw new ProgrammingError(
'"%s" is not an existing class',
$class
);
}
if (!isset(self::$hooks[$name])) {
@ -207,7 +208,10 @@ class Hook
public static function registerObject($name, $key, $object)
{
if (!is_object($object)) {
throw new ProgrammingError('"' . $object . '" is not an instantiated class');
throw new ProgrammingError(
'"%s" is not an instantiated class',
$object
);
}
if (!isset(self::$instances[$name])) {

@ -456,7 +456,10 @@ class Menu implements RecursiveIterator
public function getSubMenu($id)
{
if (false === $this->hasSubMenu($id)) {
throw new ProgrammingError('Tried to get invalid sub menu "' . $id . '"');
throw new ProgrammingError(
'Tried to get invalid sub menu "%s"',
$id
);
}
return $this->subMenus[$id];

@ -53,10 +53,8 @@ class Notification
)
)) {
throw new ProgrammingError(
sprintf(
'"%s" is not a valid notification type',
$type
)
'"%s" is not a valid notification type',
$type
);
}

@ -120,7 +120,10 @@ class Url
}
if (!is_string($url)) {
throw new ProgrammingError(sprintf('url "%s" is not a string', $url));
throw new ProgrammingError(
'url "%s" is not a string',
$url
);
}
$urlObject = new Url();

@ -103,10 +103,8 @@ class View extends Zend_View_Abstract
{
if ($this->hasHelperFunction($name)) {
throw new ProgrammingError(
sprintf(
'Cannot assign the same helper function twice: "%s"',
$name
)
'Cannot assign the same helper function twice: "%s"',
$name
);
}

@ -94,10 +94,10 @@ $this->addHelperFunction('attributeToString', function ($key, $value)
{
// TODO: Doublecheck this!
if (! preg_match('~^[a-zA-Z0-9-]+$~', $key)) {
throw new ProgrammingError(sprintf(
throw new ProgrammingError(
'Trying to set an invalid HTML attribute name: %s',
$key
));
);
}
return sprintf(

@ -38,10 +38,8 @@ class Widget
if (! class_exists($class)) {
throw new ProgrammingError(
sprintf(
'There is no such widget: %s',
$name
)
'There is no such widget: %s',
$name
);
}

@ -52,11 +52,9 @@ abstract class AbstractWidget
}
throw new ProgrammingError(
sprintf(
'Trying to get invalid "%s" property for %s',
$key,
get_class($this)
)
'Trying to get invalid "%s" property for %s',
$key,
get_class($this)
);
}
@ -78,14 +76,12 @@ abstract class AbstractWidget
}
throw new ProgrammingError(
sprintf(
'Trying to set invalid "%s" property in %s. Allowed are: %s',
$key,
get_class($this),
empty($this->properties)
'Trying to set invalid "%s" property in %s. Allowed are: %s',
$key,
get_class($this),
empty($this->properties)
? 'none'
: implode(', ', array_keys($this->properties))
)
);
}

@ -274,7 +274,8 @@ class Dashboard extends AbstractWidget
{
if (! array_key_exists($name, $this->panes)) {
throw new ProgrammingError(
sprintf('Trying to retrieve invalid dashboard pane "%s"', $name)
'Trying to retrieve invalid dashboard pane "%s"',
$name
);
}
return $this->panes[$name];

@ -105,7 +105,10 @@ class Pane extends AbstractWidget
if ($this->hasComponent($title)) {
return $this->components[$title];
}
throw new ProgrammingError(sprintf('Trying to access invalid component: %s', $title));
throw new ProgrammingError(
'Trying to access invalid component: %s',
$title
);
}
/**
@ -157,7 +160,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;
}

@ -154,10 +154,8 @@ EOT;
{
if ($this->has($name)) {
throw new ProgrammingError(
sprintf(
'Cannot add a tab named "%s" twice"',
$name
)
'Cannot add a tab named "%s" twice"',
$name
);
}
return $this->set($name, $tab);

@ -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
);
}
}
@ -147,7 +148,10 @@ public function getResource()
{
$viewClass = '\\Icinga\\Module\\Monitoring\\DataView\\' . ucfirst($viewName);
if (!class_exists($viewClass)) {
throw new ProgrammingError('DataView ' . ucfirst($viewName) . ' does not exist');
throw new ProgrammingError(
'DataView %s does not exist',
ucfirst($viewName)
);
}
return $viewClass;
}
@ -174,7 +178,9 @@ public function getResource()
. 'Query';
if (!class_exists($queryClass)) {
throw new ProgrammingError(
'Query "' . ucfirst($queryName) . '" does not exist for backend ' . ucfirst($this->type)
'Query "%s" does not exist for backend %s',
ucfirst($queryName),
ucfirst($this->type)
);
}
return $queryClass;

@ -442,7 +442,11 @@ abstract class IdoQuery extends DbQuery
} elseif ($this->isCustomVar($alias)) {
$this->requireCustomvar($alias);
} else {
throw new ProgrammingError(sprintf('%s : Got invalid column: %s', get_called_class(), $alias));
throw new ProgrammingError(
'%s : Got invalid column: %s',
get_called_class(),
$alias
);
}
return $this;
}
@ -476,7 +480,8 @@ abstract class IdoQuery extends DbQuery
{
if ($this->hasJoinedVirtualTable($name)) {
throw new ProgrammingError(
sprintf('IDO query virtual table conflict with "%s"', $name)
'IDO query virtual table conflict with "%s"',
$name
);
}
return $this;
@ -499,10 +504,8 @@ abstract class IdoQuery extends DbQuery
$this->$func();
} else {
throw new ProgrammingError(
sprintf(
'Cannot join "%s", no such table found',
$table
)
'Cannot join "%s", no such table found',
$table
);
}
$this->joinedVirtualTables[$table] = true;
@ -581,10 +584,8 @@ abstract class IdoQuery extends DbQuery
// TODO: Improve this:
if (! preg_match('~^_(host|service)_([a-zA-Z0-9_]+)$~', $customvar, $m)) {
throw new ProgrammingError(
sprintf(
'Got invalid custom var: "%s"',
$customvar
)
'Got invalid custom var: "%s"',
$customvar
);
}
return array($m[1], $m[2]);

@ -79,7 +79,9 @@ class TimeEntry
$entry->{$methodName}($value);
} else {
throw new ProgrammingError(
'Method "' . $methodName . '" does not exist on object of type "' . __CLASS__ . '"'
'Method "%s" does not exist on object of type "%s"',
$methodName,
__CLASS__
);
}
}