Entities/Roles/RolesController.php
public function routeGetDelete(Request $request, Response $response, $args)
    {
        if (!$this->authorization->isAuthorized(ROLES_DELETE_RESOURCE)) {
            throw new \Exception('No permission.');
        }

        $primaryKey = $args[ROUTEARG_PRIMARY_KEY];
        $tableName = $this->tableMapper->getFormalTableName(false);
        $primaryKeyColumnName = $this->tableMapper->getPrimaryKeyColumnName();

        try {
            $this->tableMapper->deleteByPrimaryKey($primaryKey);
            $this->events->insertInfo(EVENT_ROLE_DELETE, [$primaryKeyColumnName => $primaryKey]);
            SlimPostgres::setAdminNotice("Deleted $tableName $primaryKey");
        } catch (Exceptions\UnallowedActionException $e) {
            $this->events->insertWarning(EVENT_UNALLOWED_ACTION, ['error' => $e->getMessage()]);
            SlimPostgres::setAdminNotice($e->getMessage(), 'failure');
        } catch (Exceptions\QueryResultsNotFoundException $e) {
define('EVENT_QUERY_NO_RESULTS', 'Query Results Not Found');
            $this->events->insertWarning(EVENT_QUERY_NO_RESULTS, $e->getMessage());
            SlimPostgres::setAdminNotice($e->getMessage(), 'failure');
        } catch (Exceptions\QueryFailureException $e) {
            $this->events->insertError(EVENT_QUERY_FAIL, ['error' => $e->getMessage()]);
            SlimPostgres::setAdminNotice('Delete Failed', 'failure');
        }

        return $response->withRedirect($this->router->pathFor(SlimPostgres::getRouteName(true, $this->routePrefix, 'index')));
    }
public function routeGetDelete(Request $request, Response $response, $args)
    {
        if (!$this->authorization->isAuthorized(ROLES_DELETE_RESOURCE)) {
            throw new \Exception('No permission.');
        }

        $primaryKey = $args[ROUTEARG_PRIMARY_KEY];
        $tableName = $this->tableMapper->getFormalTableName(false);
        $primaryKeyColumnName = $this->tableMapper->getPrimaryKeyColumnName();

        try {
            $this->tableMapper->deleteByPrimaryKey($primaryKey);
            $this->events->insertInfo(EVENT_ROLE_DELETE, [$primaryKeyColumnName => $primaryKey]);
            SlimPostgres::setAdminNotice("Deleted $tableName $primaryKey");
        } catch (Exceptions\UnallowedActionException $e) {
            $this->events->insertWarning(EVENT_UNALLOWED_ACTION, ['error' => $e->getMessage()]);
            SlimPostgres::setAdminNotice($e->getMessage(), 'failure');
        } catch (Exceptions\QueryResultsNotFoundException $e) {
define('EVENT_QUERY_NO_RESULTS', 'Query Results Not Found');
            $this->events->insertWarning(EVENT_QUERY_NO_RESULTS, $e->getMessage());
            SlimPostgres::setAdminNotice($e->getMessage(), 'failure');
        } catch (Exceptions\QueryFailureException $e) {
            $this->events->insertError(EVENT_QUERY_FAIL, ['error' => $e->getMessage()]);
            SlimPostgres::setAdminNotice('Delete Failed', 'failure');
        }

        return $response->withRedirect($this->router->pathFor(SlimPostgres::getRouteName(true, $this->routePrefix, 'index')));
    }
override to check exceptions