httperr

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package httperr provides the ability to attach and extract the status code from HTTP errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorCode

func ErrorCode(err error) codes.Code

ErrorCode returns the gRPC code associated with the given error if it implements the httperr.Error interface.

func ErrorCoder

func ErrorCoder() errcode.ErrorCoder

ErrorCoder return the HTTP ErrorCoder.

func New

func New(code int, err error) error

New wraps the given error and adds an HTTP code.

func ToGRPC

func ToGRPC(httpCode int) codes.Code

ToGRPC returns the gRPC status code associated with the given HTTP status code.

Types

type Error

type Error interface {
	HTTPCode() int
	error
}

An Error is an error with an explicit HTTP code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL