~yotam/go-gemini

9397dcf089af218080b182b9ec2f460d66a3f075 — Yotam Nachum 4 years ago efc880c
Add a Gemini Error struct that contain status
1 files changed, 15 insertions(+), 0 deletions(-)

M gemini.go
M gemini.go => gemini.go +15 -0
@@ 1,5 1,7 @@
package gemini

import "fmt"

// Gemini status codes as defined in the Gemini spec Appendix 1.
const (
	StatusInput = 10


@@ 35,3 37,16 @@ const (
func SimplifyStatus(status int) int {
	return (status / 10) * 10
}

type Error struct {
	Err    error
	Status int
}

func (e Error) Error() string {
	return fmt.Sprintf("Status %d: %v", e.Status, e.Err)
}

func (e Error) Unwrap() error {
	return e.Err
}