Add proper respond http codes to service and host controller
fixes #6281
This commit is contained in:
parent
defda53ff5
commit
6df031dc78
|
@ -34,7 +34,11 @@ class ErrorController extends ActionController
|
|||
$path = preg_split('~/~', $path);
|
||||
$path = array_shift($path);
|
||||
$this->getResponse()->setHttpResponseCode(404);
|
||||
$this->view->message = $this->translate('Page not found.');
|
||||
$title = preg_replace('/\r?\n.*$/s', '', $exception->getMessage());
|
||||
$this->view->title = 'Server error: ' . $title;
|
||||
if ($this->getInvokeArg('displayExceptions')) {
|
||||
$this->view->stackTrace = $exception->getTraceAsString();
|
||||
}
|
||||
if ($modules->hasInstalled($path) && ! $modules->hasEnabled($path)) {
|
||||
$this->view->message .= ' ' . sprintf(
|
||||
$this->translate('Enabling the "%s" module might help!'),
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
use Icinga\Exception\MissingParameterException;
|
||||
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
||||
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
||||
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
||||
|
@ -26,12 +27,22 @@ class Monitoring_HostController extends MonitoredObjectController
|
|||
*/
|
||||
public function init()
|
||||
{
|
||||
if ($this->params->get('host') === null) {
|
||||
throw new MissingParameterException(
|
||||
$this->translate('Required parameter \'%s\' is missing'),
|
||||
'host'
|
||||
);
|
||||
}
|
||||
|
||||
$host = new Host($this->backend, $this->params->get('host'));
|
||||
|
||||
$this->applyRestriction('monitoring/hosts/filter', $host);
|
||||
|
||||
if ($host->fetch() === false) {
|
||||
throw new Zend_Controller_Action_Exception($this->translate('Host not found'));
|
||||
throw new Zend_Controller_Action_Exception(
|
||||
sprintf($this->translate('Host \'%s\' not found'), $this->params->get('host')),
|
||||
404
|
||||
);
|
||||
}
|
||||
$this->object = $host;
|
||||
$this->createTabs();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
use Icinga\Exception\MissingParameterException;
|
||||
use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm;
|
||||
use Icinga\Module\Monitoring\Forms\Command\Object\AddCommentCommandForm;
|
||||
use Icinga\Module\Monitoring\Forms\Command\Object\ProcessCheckResultCommandForm;
|
||||
|
@ -25,12 +26,22 @@ class Monitoring_ServiceController extends MonitoredObjectController
|
|||
*/
|
||||
public function init()
|
||||
{
|
||||
if ($this->params->get('host') === null || $this->params->get('service') === null) {
|
||||
throw new MissingParameterException(
|
||||
$this->translate('One of the required parameters \'%s\' is missing'),
|
||||
'host or service'
|
||||
);
|
||||
}
|
||||
|
||||
$service = new Service($this->backend, $this->params->get('host'), $this->params->get('service'));
|
||||
|
||||
$this->applyRestriction('monitoring/services/filter', $service);
|
||||
|
||||
if ($service->fetch() === false) {
|
||||
throw new Zend_Controller_Action_Exception($this->translate('Service not found'));
|
||||
throw new Zend_Controller_Action_Exception(
|
||||
sprintf($this->translate('Service \'%s\' not found'), $this->params->get('service')),
|
||||
404
|
||||
);
|
||||
}
|
||||
$this->object = $service;
|
||||
$this->createTabs();
|
||||
|
|
Loading…
Reference in New Issue