func FromHTTPStatusCode(status int, publicAttributes ...string) *Error {
	code := uint32(codes.Unknown)
	if c, ok := httpErrorCodes[status]; ok {
		code = c
	}
	return build(&Definition{
		namespace:        namespace(2),
		messageFormat:    http.StatusText(status),
		publicAttributes: publicAttributes,
		code:             code,
	}, 4)
}
FromHTTPStatusCode maps an HTTP response code to an error.
package errors
import (
	"encoding/json"
	"net/http"
	"google.golang.org/grpc/codes"
)
var httpStatusCodes = map[uint32]int{
	uint32(codes.OK):                 http.StatusOK,
	uint32(codes.Canceled):           499,  
	uint32(codes.Unknown):            http.StatusInternalServerError,
	uint32(codes.InvalidArgument):    http.StatusBadRequest,
	uint32(codes.DeadlineExceeded):   http.StatusGatewayTimeout,
	uint32(codes.NotFound):           http.StatusNotFound,
	uint32(codes.AlreadyExists):      http.StatusConflict,
	uint32(codes.PermissionDenied):   http.StatusForbidden,
	uint32(codes.Unauthenticated):    http.StatusUnauthorized,
	uint32(codes.ResourceExhausted):  http.StatusTooManyRequests,
	uint32(codes.FailedPrecondition): http.StatusBadRequest,
	uint32(codes.Aborted):            http.StatusConflict,
	uint32(codes.OutOfRange):         http.StatusBadRequest,
	uint32(codes.Unimplemented):      http.StatusNotImplemented,
	uint32(codes.Internal):           http.StatusInternalServerError,
	uint32(codes.Unavailable):        http.StatusServiceUnavailable,
	uint32(codes.DataLoss):           http.StatusInternalServerError,
}
var httpErrorCodes = map[int]uint32{
	http.StatusOK:                  uint32(codes.OK),
	499:                            uint32(codes.Canceled),  
	http.StatusInternalServerError: uint32(codes.Unknown),
	http.StatusBadRequest:          uint32(codes.InvalidArgument),
	http.StatusGatewayTimeout:      uint32(codes.DeadlineExceeded),
	http.StatusNotFound:            uint32(codes.NotFound),
	http.StatusConflict:            uint32(codes.AlreadyExists),
	http.StatusForbidden:           uint32(codes.PermissionDenied),
	http.StatusUnauthorized:        uint32(codes.Unauthenticated),
	http.StatusTooManyRequests:     uint32(codes.ResourceExhausted),
	http.StatusNotImplemented:      uint32(codes.Unimplemented),
	http.StatusServiceUnavailable:  uint32(codes.Unavailable),
}
func ToHTTPStatusCode(err error) int {
	for _, err := range Stack(err) {
		code := Code(err)
		if code == uint32(codes.Unknown) {
			continue
		}
		if status, ok := httpStatusCodes[code]; ok {
			return status
		}
	}
	return http.StatusInternalServerError
}