mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
display no permission error message at the right place
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
class NoPermissionException extends \Exception
|
||||
{
|
||||
// Redefine the exception so message isn't optional
|
||||
public function __construct($message, $code = 0, ?\Throwable $previous = null) {
|
||||
|
||||
// make sure everything is assigned properly
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
// custom string representation of object
|
||||
public function __toString() {
|
||||
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,10 +12,12 @@ require_once __DIR__ . '/VertragsbestandteilFreitext.php';
|
||||
require_once __DIR__ . '/VertragsbestandteilKarenz.php';
|
||||
require_once __DIR__ . '/VertragsbestandteilFactory.php';
|
||||
require_once __DIR__ . '/OverlapChecker.php';
|
||||
require_once __DIR__ . '/NoPermissionException.php';
|
||||
|
||||
use vertragsbestandteil\Dienstverhaeltnis;
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
use vertragsbestandteil\NoPermissionException;
|
||||
|
||||
/**
|
||||
* Description of VertragsbestandteilLib
|
||||
@@ -251,8 +253,12 @@ class VertragsbestandteilLib
|
||||
throw new Exception("Transaction failed");
|
||||
}
|
||||
$this->CI->db->trans_commit();
|
||||
}
|
||||
catch (Exception $ex)
|
||||
} catch (NoPermissionException $e) {
|
||||
log_message('debug', "Transaction rolled back. " . $e->getMessage());
|
||||
$this->CI->db->trans_rollback();
|
||||
// rethrow and let GUIHandler catch it to display error message
|
||||
throw $e;
|
||||
} catch (Exception $ex)
|
||||
{
|
||||
log_message('debug', "Transaction rolled back. " . $ex->getMessage());
|
||||
$this->CI->db->trans_rollback();
|
||||
@@ -337,7 +343,7 @@ class VertragsbestandteilLib
|
||||
|
||||
if (!$hasGehaltsPermission && $vbHasGehaltsbestandteile)
|
||||
{
|
||||
throw new Exception('delete Gehaltsbestandteil permission denied');
|
||||
throw new NoPermissionException('delete Gehaltsbestandteil permission denied');
|
||||
}
|
||||
|
||||
$specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel(
|
||||
|
||||
Reference in New Issue
Block a user