github.com/cloudwego/kitex@v0.9.0/pkg/remote/trans/nphttp2/grpc/grpcframe/errors.go (about) 1 /* 2 * Copyright 2014 The Go Authors. All rights reserved. 3 * Use of this source code is governed by a BSD-style 4 * license that can be found in the LICENSE file. 5 * 6 * Code forked from golang v1.17.4 7 */ 8 9 package grpcframe 10 11 import ( 12 "errors" 13 "fmt" 14 15 "golang.org/x/net/http2" 16 ) 17 18 // connError represents an HTTP/2 ConnectionError error code, along 19 // with a string (for debugging) explaining why. 20 // 21 // Errors of this type are only returned by the frame parser functions 22 // and converted into ConnectionError(Code), after stashing away 23 // the Reason into the Framer's errDetail field, accessible via 24 // the (*Framer).ErrorDetail method. 25 type connError struct { 26 Code http2.ErrCode // the ConnectionError error code 27 Reason string // additional reason 28 } 29 30 func (e connError) Error() string { 31 return fmt.Sprintf("http2: connection error: %v: %v", e.Code, e.Reason) 32 } 33 34 type pseudoHeaderError string 35 36 func (e pseudoHeaderError) Error() string { 37 return fmt.Sprintf("invalid pseudo-header %q", string(e)) 38 } 39 40 type duplicatePseudoHeaderError string 41 42 func (e duplicatePseudoHeaderError) Error() string { 43 return fmt.Sprintf("duplicate pseudo-header %q", string(e)) 44 } 45 46 type headerFieldNameError string 47 48 func (e headerFieldNameError) Error() string { 49 return fmt.Sprintf("invalid header field name %q", string(e)) 50 } 51 52 type headerFieldValueError string 53 54 func (e headerFieldValueError) Error() string { 55 return fmt.Sprintf("invalid header field value %q", string(e)) 56 } 57 58 var ( 59 errMixPseudoHeaderTypes = errors.New("mix of request and response pseudo headers") 60 errPseudoAfterRegular = errors.New("pseudo header field after regular") 61 )