added custom error page; updated middleware to use it