github.com/apernet/quic-go@v0.43.1-0.20240515053213-5e9e635fd9f0/errors.go (about) 1 package quic 2 3 import ( 4 "fmt" 5 6 "github.com/apernet/quic-go/internal/qerr" 7 ) 8 9 type ( 10 TransportError = qerr.TransportError 11 ApplicationError = qerr.ApplicationError 12 VersionNegotiationError = qerr.VersionNegotiationError 13 StatelessResetError = qerr.StatelessResetError 14 IdleTimeoutError = qerr.IdleTimeoutError 15 HandshakeTimeoutError = qerr.HandshakeTimeoutError 16 ) 17 18 type ( 19 TransportErrorCode = qerr.TransportErrorCode 20 ApplicationErrorCode = qerr.ApplicationErrorCode 21 StreamErrorCode = qerr.StreamErrorCode 22 ) 23 24 const ( 25 NoError = qerr.NoError 26 InternalError = qerr.InternalError 27 ConnectionRefused = qerr.ConnectionRefused 28 FlowControlError = qerr.FlowControlError 29 StreamLimitError = qerr.StreamLimitError 30 StreamStateError = qerr.StreamStateError 31 FinalSizeError = qerr.FinalSizeError 32 FrameEncodingError = qerr.FrameEncodingError 33 TransportParameterError = qerr.TransportParameterError 34 ConnectionIDLimitError = qerr.ConnectionIDLimitError 35 ProtocolViolation = qerr.ProtocolViolation 36 InvalidToken = qerr.InvalidToken 37 ApplicationErrorErrorCode = qerr.ApplicationErrorErrorCode 38 CryptoBufferExceeded = qerr.CryptoBufferExceeded 39 KeyUpdateError = qerr.KeyUpdateError 40 AEADLimitReached = qerr.AEADLimitReached 41 NoViablePathError = qerr.NoViablePathError 42 ) 43 44 // A StreamError is used for Stream.CancelRead and Stream.CancelWrite. 45 // It is also returned from Stream.Read and Stream.Write if the peer canceled reading or writing. 46 type StreamError struct { 47 StreamID StreamID 48 ErrorCode StreamErrorCode 49 Remote bool 50 } 51 52 func (e *StreamError) Is(target error) bool { 53 _, ok := target.(*StreamError) 54 return ok 55 } 56 57 func (e *StreamError) Error() string { 58 pers := "local" 59 if e.Remote { 60 pers = "remote" 61 } 62 return fmt.Sprintf("stream %d canceled by %s with error code %d", e.StreamID, pers, e.ErrorCode) 63 } 64 65 // DatagramTooLargeError is returned from Connection.SendDatagram if the payload is too large to be sent. 66 type DatagramTooLargeError struct { 67 MaxDataLen int64 68 } 69 70 func (e *DatagramTooLargeError) Is(target error) bool { 71 _, ok := target.(*DatagramTooLargeError) 72 return ok 73 } 74 75 func (e *DatagramTooLargeError) Error() string { return "DATAGRAM frame too large" }