github.com/sagernet/quic-go@v0.43.1-beta.1/http3/error_codes.go (about)

     1  package http3
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/sagernet/quic-go"
     7  )
     8  
     9  type ErrCode quic.ApplicationErrorCode
    10  
    11  const (
    12  	ErrCodeNoError              ErrCode = 0x100
    13  	ErrCodeGeneralProtocolError ErrCode = 0x101
    14  	ErrCodeInternalError        ErrCode = 0x102
    15  	ErrCodeStreamCreationError  ErrCode = 0x103
    16  	ErrCodeClosedCriticalStream ErrCode = 0x104
    17  	ErrCodeFrameUnexpected      ErrCode = 0x105
    18  	ErrCodeFrameError           ErrCode = 0x106
    19  	ErrCodeExcessiveLoad        ErrCode = 0x107
    20  	ErrCodeIDError              ErrCode = 0x108
    21  	ErrCodeSettingsError        ErrCode = 0x109
    22  	ErrCodeMissingSettings      ErrCode = 0x10a
    23  	ErrCodeRequestRejected      ErrCode = 0x10b
    24  	ErrCodeRequestCanceled      ErrCode = 0x10c
    25  	ErrCodeRequestIncomplete    ErrCode = 0x10d
    26  	ErrCodeMessageError         ErrCode = 0x10e
    27  	ErrCodeConnectError         ErrCode = 0x10f
    28  	ErrCodeVersionFallback      ErrCode = 0x110
    29  	ErrCodeDatagramError        ErrCode = 0x33
    30  )
    31  
    32  func (e ErrCode) String() string {
    33  	s := e.string()
    34  	if s != "" {
    35  		return s
    36  	}
    37  	return fmt.Sprintf("unknown error code: %#x", uint16(e))
    38  }
    39  
    40  func (e ErrCode) string() string {
    41  	switch e {
    42  	case ErrCodeNoError:
    43  		return "H3_NO_ERROR"
    44  	case ErrCodeGeneralProtocolError:
    45  		return "H3_GENERAL_PROTOCOL_ERROR"
    46  	case ErrCodeInternalError:
    47  		return "H3_INTERNAL_ERROR"
    48  	case ErrCodeStreamCreationError:
    49  		return "H3_STREAM_CREATION_ERROR"
    50  	case ErrCodeClosedCriticalStream:
    51  		return "H3_CLOSED_CRITICAL_STREAM"
    52  	case ErrCodeFrameUnexpected:
    53  		return "H3_FRAME_UNEXPECTED"
    54  	case ErrCodeFrameError:
    55  		return "H3_FRAME_ERROR"
    56  	case ErrCodeExcessiveLoad:
    57  		return "H3_EXCESSIVE_LOAD"
    58  	case ErrCodeIDError:
    59  		return "H3_ID_ERROR"
    60  	case ErrCodeSettingsError:
    61  		return "H3_SETTINGS_ERROR"
    62  	case ErrCodeMissingSettings:
    63  		return "H3_MISSING_SETTINGS"
    64  	case ErrCodeRequestRejected:
    65  		return "H3_REQUEST_REJECTED"
    66  	case ErrCodeRequestCanceled:
    67  		return "H3_REQUEST_CANCELLED"
    68  	case ErrCodeRequestIncomplete:
    69  		return "H3_INCOMPLETE_REQUEST"
    70  	case ErrCodeMessageError:
    71  		return "H3_MESSAGE_ERROR"
    72  	case ErrCodeConnectError:
    73  		return "H3_CONNECT_ERROR"
    74  	case ErrCodeVersionFallback:
    75  		return "H3_VERSION_FALLBACK"
    76  	case ErrCodeDatagramError:
    77  		return "H3_DATAGRAM_ERROR"
    78  	default:
    79  		return ""
    80  	}
    81  }