- Move to $GOPATH/src/my-first-beego-project/controllers and create errorcontroller.go, where we will define handlers to handle 404 and 500 HTTP errors as well as the handler to handle any generic error in an application, as follows:
package controllersimport "github.com/astaxie/beego"type ErrorController struct { beego.Controller}func (c *ErrorController) Error404() { c.Data["content"] = "Page Not Found" c.TplName = "404.tpl"}func (c *ErrorController) Error500() { c.Data["content"] = "Internal Server Error" c.TplName = "500.tpl"}func (c *ErrorController) ErrorGeneric() { c.Data["content"] = "Some Error Occurred" c.TplName = "genericerror.tpl"}
- Move to $GOPATH/src/my-first-beego-project/controllers and edit firstcontroller.go ...