Throws error when getting non-existent (out of bounds) page

Attempting to fix #3611.

Not sure if this is the write place to put the check. All feedback appreciated.