Exception thrown in the menu part in some cases

In some cases the current page return null and there was an exception being thrown creating the cache key.