Database Catch error

So in my application if i change the url slug it will search my database with a url that matches , example :

http://sandbox.dev/areas/category/books/ book_name

Where book_name will be the respected url slug to fetch in the database , but if there is no match , how can i grab that in my controller ? For now it just returns the default message : The index does not exist in the cursor

The error is raised here: which means that a position in a resulset is being accessed without the resultset actually having a record in that position.

https://github.com/phalcon/cphalcon/blob/2.0.x/phalcon/mvc/model/resultset.zep#L243

yeah , but how do i detect if there is no results in the controller so i can route to a other controller ?

I don't know how is the application working internally but:

public function someAction()
{
    $resultset = /// here obtains the resulset
    if ($index >= count($resultset)) {
        return $this->response->redirect('/some/action/when-no-results');
    }
}