Replace usage of LogicException with AlreadyExistsException where applicable

This commit is contained in:
Yonas Habteab 2022-06-07 12:23:45 +02:00
parent 395ae80186
commit 89b95d74bf
7 changed files with 17 additions and 10 deletions

View File

@ -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,

View File

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

View File

@ -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
*/

View File

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

View File

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

View File

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

View File

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