private function databaseRecordNotFound(Response $response, $primaryKey, TableMapper $tableMapper, string $routeAction, ?string $title = null)
    {
        // $routeAction must be 'update' or 'delete'
        if ($routeAction != 'update' && $routeAction != 'delete') {
            throw new \Exception("routeAction $routeAction must be update or delete");
        }

        // enter event
        $this->events->insertWarning(EVENT_QUERY_NO_RESULTS, [$tableMapper->getPrimaryKeyColumnName() => $primaryKey, 'table' => $tableMapper->getTableName()]);

        $noticeTitle = ($title != null) ? $title: 'Record';
        SlimPostgres::setAdminNotice("$noticeTitle $primaryKey Not Found", 'failure');
        
        return $response->withRedirect($this->router->pathFor(SlimPostgres::getRouteName(true, $this->routePrefix, 'index')));
    }