Skip to content

debyten/apierr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

apierr

This library is a utility for creating errors with the use of standard http status codes. The built error is a Problem (from schneider.vip/problem).

The error handling on the api side will be simplified as follows:

package main

import (
	"github.com/debyten/apierr"
	"net/http"
)

func exampleErr() error {
	return apierr.NotFound.Problem("entity not found")
}

func myHandler(w http.ResponseWriter, r *http.Request) {
	err := exampleErr()
	if err != nil {
        apierr.HandleISE(err, w)
		return
	}
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages