parent
7074fa1331
commit
febb2d1ae2
|
@ -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;
|
||||
|
|
|
@ -323,10 +323,8 @@ class Manager
|
|||
}
|
||||
|
||||
throw new ProgrammingError(
|
||||
sprintf(
|
||||
'Trying to access uninstalled module dir: %s',
|
||||
$name
|
||||
)
|
||||
'Trying to access uninstalled module dir: %s',
|
||||
$name
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -392,10 +390,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];
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,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'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,6 @@ namespace Icinga\Exception;
|
|||
* Class ProgrammingError
|
||||
* @package Icinga\Exception
|
||||
*/
|
||||
class ProgrammingError extends \Exception
|
||||
class ProgrammingError extends IcingaException
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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])) {
|
||||
|
|
|
@ -277,7 +277,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))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,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
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -148,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;
|
||||
}
|
||||
|
@ -175,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__
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue