简体   繁体   English

是否可以在Google App Engine上使用Go设置默认错误页面

[英]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.

相关问题 如何在 Google App Engine 上设置自定义 404 页面 (go) - How to set up a custom 404 page on Google app Engine (go) 谷歌应用程序引擎:通过javascript进入登录页面? - google app engine: go to login page by javascript? 在App Engine上使用Google Application Default Credentials时出错 - Error when using Google Application Default Credentials on App Engine 是否可以使用默认的Google页面模板创建Google App Engine Web应用程序? - Is it possible to create google app engine web application with default google page template? 将Go应用程序部署到Google App Engine时出错 - Error deploying Go apps to Google App Engine 使用GO的Google App Engine的Cloud IDE - Cloud IDE for Google App Engine using GO 使用Go Runtime Google App Engine时出现Google云端存储客户端应用错误 - Google Cloud Storage Client App error using Go Runtime Google App Engine Google App Engine(go)是否可以使用用户本地网络浏览器时区格式化日期? - Is it possible in google app engine (go) to format a date using the users local web browser timezone? Google App Engine-设置索引/主页 - Google App Engine - set index/home page 谷歌应用程序引擎 - 为php设置404页面 - google app engine - set 404 page for php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM