github.com/storacha/go-ucanto@v0.7.2/transport/http/error.go (about)

     1  package http
     2  
     3  import (
     4  	nethttp "net/http"
     5  
     6  	"github.com/storacha/go-ucanto/transport"
     7  )
     8  
     9  type httpError struct {
    10  	message string
    11  	status  int
    12  	headers nethttp.Header
    13  }
    14  
    15  func (err *httpError) Error() string {
    16  	return err.message
    17  }
    18  
    19  func (err *httpError) Name() string {
    20  	return "HTTPError"
    21  }
    22  
    23  func (err *httpError) Status() int {
    24  	return err.status
    25  }
    26  
    27  func (err *httpError) Headers() nethttp.Header {
    28  	return err.headers
    29  }
    30  
    31  func NewHTTPError(message string, status int, headers nethttp.Header) transport.HTTPError {
    32  	return &httpError{message, status, headers}
    33  }