How to do it...

  1. 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"}
  1. Move to $GOPATH/src/my-first-beego-project/controllers and edit firstcontroller.go ...

Get Go Web Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.