error-handlers on app.yaml

2019-07-24 09:39发布

问题:

How to handle different error codes on app engine? In my app.yaml file, I have-

error_handlers:
  - file: error/notfound.html

  - error_code: over_quota
    file: error/over_quota.html

handlers:
..some handlers..

This doesn't seem to work. If my site doesn't have a folder name foo and a user looks for http://mysite.com/foo, it just returns a standard 404 error, not the page I specified on app.yaml.

My static dir is separate from error dir. Both error and static dirs are inside project dir. What am I missing?

Is there a way to show custom page rather than a custom response message?

回答1:

The 404 error handler page will only be displayed if a URL fails to match any patterns in app.yaml. If your app is returning a 404, it's up to the app to display the error page you want - there's no way to tell the framework to display the default error page instead.