I definitely like moving the error handling out of the paging functions, but I'm not sure it belongs here. Perhaps a outer-level middleware function that just handles converting exceptions to 500s would be appropriate.