mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-25 18:59:04 +02:00
Replace usage of LogicException
with AlreadyExistsException
where applicable
This commit is contained in:
parent
395ae80186
commit
89b95d74bf
@ -32,10 +32,11 @@ CREATE TABLE `icingaweb_dashlet` (
|
||||
`label` VARCHAR NOT NULL,
|
||||
`url` VARCHAR NOT NULL,
|
||||
`priority` tinyint NOT NULL,
|
||||
`disabled` TEXT CHECK ( disabled IN ('n', 'y') ) DEFAULT 'n',
|
||||
`disabled` TEXT CHECK ( disabled IN ('n', 'y') ) DEFAULT 'n',
|
||||
FOREIGN KEY (`dashboard_id`) REFERENCES `icingaweb_dashboard` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- TODO: Remove me once we have decoupled module dashlets (as a daemon job) from the actual dashboards loading action!!
|
||||
CREATE TABLE `icingaweb_module_dashlet` (
|
||||
`id` binary(20) NOT NULL PRIMARY KEY,
|
||||
`name` VARCHAR NOT NULL,
|
||||
|
@ -4,9 +4,10 @@
|
||||
|
||||
namespace Icinga\Web\Dashboard\Common;
|
||||
|
||||
use Icinga\Exception\NotImplementedError;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
|
||||
use Icinga\Web\Dashboard\Dashboard;
|
||||
|
||||
use function ipl\Stdlib\get_php_type;
|
||||
|
||||
trait DashboardEntries
|
||||
@ -82,6 +83,7 @@ trait DashboardEntries
|
||||
|
||||
public function createEntry(string $name, $url = null)
|
||||
{
|
||||
throw new NotImplementedError('Not yet implemented by the concrete class!!');
|
||||
}
|
||||
|
||||
public function rewindEntries()
|
||||
|
@ -61,8 +61,8 @@ trait WidgetState
|
||||
/**
|
||||
* Get whether this widget is currently being loaded
|
||||
*
|
||||
* This indicates which dashboard tab is currently open if this widget type is a Dashboard Pane
|
||||
* or whether the Dashboard Home in the navigation bar is active/focused
|
||||
* Indicates which dashboard tab is currently open if this widget is a Dashboard Pane type
|
||||
* or whether the Dashboard Home is active/focused in the navigation bar
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
namespace Icinga\Web\Dashboard;
|
||||
|
||||
use Icinga\Exception\AlreadyExistsException;
|
||||
use Icinga\Exception\Http\HttpNotFoundException;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Model\Home;
|
||||
@ -244,11 +245,11 @@ class DashboardHome extends BaseDashboard implements Sortable
|
||||
} else {
|
||||
// Failed to move the pane! Should have already been handled by the caller,
|
||||
// though I think it's better that we raise an exception here!!
|
||||
throw new \LogicException(sprintf(
|
||||
throw new AlreadyExistsException(
|
||||
'Dashboard Pane "%s" could not be managed. Dashboard Home "%s" has Pane with the same name!',
|
||||
$pane->getTitle(),
|
||||
$this->getTitle()
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
$pane->setHome($this);
|
||||
|
@ -5,6 +5,7 @@
|
||||
namespace Icinga\Web\Dashboard;
|
||||
|
||||
use Icinga\Application\Modules;
|
||||
use Icinga\Exception\AlreadyExistsException;
|
||||
use Icinga\Web\Dashboard\Common\BaseDashboard;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
@ -238,11 +239,11 @@ class Pane extends BaseDashboard implements Sortable
|
||||
} else {
|
||||
// Failed to move the pane! Should have already been handled by the caller,
|
||||
// though I think it's better that we raise an exception here!!
|
||||
throw new \LogicException(sprintf(
|
||||
throw new AlreadyExistsException(
|
||||
'Dashlet "%s" could not be managed. Dashboard Pane "%s" has a Dashlet with the same name!',
|
||||
$dashlet->getTitle(),
|
||||
$this->getTitle()
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
$dashlet->setPane($this);
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
namespace Tests\Icinga\Web\Dashboard;
|
||||
|
||||
use Icinga\Exception\AlreadyExistsException;
|
||||
use Icinga\Test\BaseDashboardTestCase;
|
||||
use Icinga\Web\Dashboard\Dashlet;
|
||||
use Icinga\Web\Dashboard\Pane;
|
||||
@ -169,7 +170,7 @@ class DashletTest extends BaseDashboardTestCase
|
||||
|
||||
public function testWhetherManageEntryThrowsAnExceptionOnDuplicatedError()
|
||||
{
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectException(AlreadyExistsException::class);
|
||||
|
||||
$default = $this->getTestHome();
|
||||
$this->dashboard->manageEntry($default);
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
namespace Tests\Icinga\Web\Dashboard;
|
||||
|
||||
use Icinga\Exception\AlreadyExistsException;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Test\BaseDashboardTestCase;
|
||||
use Icinga\Web\Dashboard\DashboardHome;
|
||||
@ -176,7 +177,7 @@ class PaneTest extends BaseDashboardTestCase
|
||||
|
||||
public function testWhetherManageEntryThrowsAnExceptionOnDuplicatedError()
|
||||
{
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectException(AlreadyExistsException::class);
|
||||
|
||||
$default = $this->getTestHome();
|
||||
$home = $this->getTestHome('Second Home');
|
||||
|
Loading…
x
Reference in New Issue
Block a user