creates error_handler middleware to replace decorator on all pages