rewrite error handling so page gets rendered inside the error clause