Browse Source

http2: add Framer.ErrorDetail method

Change-Id: Ida47c3feab7bfb0f12bf832953e16d167e6547dd
Reviewed-on: https://go-review.googlesource.com/19917
Reviewed-by: Andrew Gerrand <adg@golang.org>
Brad Fitzpatrick 9 years ago
parent
commit
6acef71eb6
1 changed files with 11 additions and 0 deletions
  1. 11 0
      http2/frame.go

+ 11 - 0
http2/frame.go

@@ -424,6 +424,17 @@ func (fr *Framer) SetMaxReadFrameSize(v uint32) {
 	fr.maxReadSize = v
 	fr.maxReadSize = v
 }
 }
 
 
+// ErrorDetail returns a more detailed error of the last error
+// returned by Framer.ReadFrame. For instance, if ReadFrame
+// returns a StreamError with code PROTOCOL_ERROR, ErrorDetail
+// will say exactly what was invalid. ErrorDetail is not guaranteed
+// to return a non-nil value and like the rest of the http2 package,
+// its return value is not protected by an API compatibility promise.
+// ErrorDetail is reset after the next call to ReadFrame.
+func (fr *Framer) ErrorDetail() error {
+	return fr.errDetail
+}
+
 // ErrFrameTooLarge is returned from Framer.ReadFrame when the peer
 // ErrFrameTooLarge is returned from Framer.ReadFrame when the peer
 // sends a frame that is larger than declared with SetMaxReadFrameSize.
 // sends a frame that is larger than declared with SetMaxReadFrameSize.
 var ErrFrameTooLarge = errors.New("http2: frame too large")
 var ErrFrameTooLarge = errors.New("http2: frame too large")