Documentation
¶
Overview ¶
Package httperr contains the helper for extracting HTTP status code from a semerr.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Code ¶
Code returns http status code for err. In case of joined errors it returns the first code found in the chain.
Example ¶
package main import ( "errors" "fmt" "net/http" "github.com/hedhyw/semerr/pkg/v1/httperr" "github.com/hedhyw/semerr/pkg/v1/semerr" ) func main() { err := semerr.NewBadRequestError(errors.New("bad request error")) fmt.Println( "Is err bad request?", httperr.Code(err) == http.StatusBadRequest, ) }
Output: Is err bad request? true
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.