Skip to content

Commit

Permalink
Add SystemPermissionException
Browse files Browse the repository at this point in the history
This exception should be fired when the OS restricts the web user
from executing certain actions. Also the template for errors has
been modified so it displays the action and the target that
was prevented.

refs #4092
  • Loading branch information
Jannis Moßhammer authored and mxhash committed Jun 26, 2013
1 parent 901a49b commit 5c16756
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
3 changes: 1 addition & 2 deletions application/controllers/ErrorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public function errorAction()
$this->view->message = 'Application error';
break;
}

// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
Expand All @@ -44,4 +43,4 @@ public function errorAction()
}
}

// @codingStandardsIgnoreEnd
// @codingStandardsIgnoreEnd
11 changes: 9 additions & 2 deletions application/views/scripts/error/error.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@
<div style="text-align:left;">
<h3>Exception information:</h3>

<p >
<b>Message:</b> <?php echo $this->exception->getMessage() ?>
<p>
<b>Message:</b> <?php echo $this->exception->getMessage() ?>
<?php if (isset($this->exception->action)): ?>
<br/><b>Action</b>: <?= $this->exception->action; ?>
<?php endif ?>
<?php if (isset($this->exception->action)): ?>
<br/><b>Target</b>: <?= $this->exception->target; ?>
<?php endif ?>

</p>

<h3>Stack trace:</h3>
Expand Down
22 changes: 22 additions & 0 deletions library/Icinga/Exception/SystemPermissionException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}

namespace Icinga\Exception;

/**
* Class ProgrammingError
* @package Icinga\Exception
*/
class SystemPermissionException extends \Exception
{
public $action;
public $target;

public function __construct($message, $action, $target = "")
{
parent::__construct($message);
$this->action = $action;
$this->target = $target;
}
}

0 comments on commit 5c16756

Please sign in to comment.