[英]Is it possible to set a default error page using Go on Google App Engine
I've previously worked with J2EE where it's possible to add this configuration to web.xml
我以前曾与J2EE一起工作过,可以在此将配置添加到
web.xml
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error</location>
</error-page>
The effect of the above code is that if an unhanded exception is thrown, it will be passed to the /error
page, which will be shown to the user. 上面的代码的作用是,如果引发了未处理的异常,它将被传递到
/error
页面,该页面将显示给用户。
Is there a way to do something similar to this when my Go web application panics on Google App Engine? 当我的Go Web应用在Google App Engine上出现恐慌时,有什么方法可以做类似的事情?
Yes, see Custom error responses : 是的,请参阅自定义错误响应 :
When certain errors occur, App Engine serves a generic error page.
当发生某些错误时,App Engine会提供通用错误页面。 You can configure your app to serve a custom static file instead of these generic error pages, so long as the custom error data is less than 10 kilobytes.
您可以将应用程序配置为提供自定义静态文件,而不是这些常规错误页面,只要自定义错误数据小于10 KB。 You can set up different static files to be served for each supported error code by specifying the files in your app's app.yaml file.
通过在应用程序的app.yaml文件中指定文件,可以为每个受支持的错误代码设置不同的静态文件以供使用。 To serve custom error pages, add a error_handlers section to your app.yaml, as in this example:
要提供自定义错误页面,请在您的app.yaml中添加error_handlers部分,如下例所示:
error_handlers: - file: default_error.html - error_code: over_quota file: over_quota.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.