Error handling

As mentioned in the Go language blog Error handling and Go, error handling is important: "The language's design and conventions encourage you to explicitly check for errors where they occur (as distinct from the convention in other languages of throwing exceptions and sometimes catching them)". Within the Echo framework, you may have noticed that every single handler function returns an error. In the following code, we will explore what happens when a handler returns an error. In this case, we will make a new handler in $GOPATH/src/github.com/PacktPublishing/Echo-Essentials/chapter6/handlers/err.go, which looks like the following:

package handlers import ( "errors" "github.com/labstack/echo" ) // Error - Example Error Handler ...

Get Echo Quick Start Guide 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.