Errors
General Error Variables
Section titled “General Error Variables”The following error variables are defined with the prefix Err and are used for general-purpose error handling:
| Variable Name | Error Message | Description (inferred) |
|---|---|---|
moqt.ErrInvalidScheme |
“moqt: invalid scheme” | Invalid URL scheme (only https and moqt are supported) |
moqt.ErrClosedSession |
“moqt: closed session” | Session has been closed |
moqt.ErrServerClosed |
“moqt: server closed” | Server has been closed |
Protocol Error Types
Section titled “Protocol Error Types”The following error types are defined to represent specific protocol error scenarios. Each type wraps error codes and provides methods for error handling and inspection:
| Error Type | Description | Returned By |
|---|---|---|
*moqt.SessionError |
Error related to session management and protocol | moqt.Session, or instance originating from it |
*moqt.SubscribeError |
Error during subscribe negotiation or operation | moqt.TrackWriter, moqt.TrackReader |
*moqt.AnnounceError |
Error during announcement phase (e.g., broadcast path issues) | moqt.AnnouncementWriter, moqt.AnnouncementReader |
*moqt.GroupError |
Error in group operations (e.g., out of range, expired group) | moqt.GroupWriter, moqt.GroupReader |
*moqt.FetchError |
Error during fetch operations | Session.Fetch |
*moqt.ProbeError |
Error during probe operations | Session.Probe |
Relationship with QUIC errors
Section titled “Relationship with QUIC errors”The concrete MoQ error types map directly onto the QUIC error primitives:
moqt.SessionErrorwraps*transport.ApplicationErrorand represents errors that affect the whole QUIC connection (session-level errors).moqt.AnnounceError,moqt.SubscribeError,moqt.GroupError,moqt.FetchError, andmoqt.ProbeErroreach wrap*transport.StreamErrorand represent errors that occur on individual QUIC streams (stream-level errors).
This mapping allows protocol-specific error types to be propagated over QUIC using the appropriate QUIC error mechanism.
Each error type implements the error interface as a pointer, which is how the library returns it: match it with errors.As and a target such as var subErr *moqt.SubscribeError. A target of the value type is reported by go vet, and makes errors.As panic.
Built-in Error Codes
Section titled “Built-in Error Codes”moq-lite-06 defines two independent code spaces: one for closing the session and one for resetting a stream. The same number means different things in each. Both reserve 0x20–0x2F (never sent, never interpreted), reuse moq-transport’s codes below 0x20, and leave 0x40 and up to the application. moq-lite’s own stream codes sit at 0x30–0x39.
Every stream code type below (AnnounceErrorCode, SubscribeErrorCode, GroupErrorCode, FetchErrorCode, ProbeErrorCode) is a view of the one stream space, so two types share a value where they share a meaning. Where gomoqt needs a code moq-lite does not define, it is assigned from 0x40 up; a peer that is not gomoqt treats it as an unspecified error.
Note that a stream reset with 0x0 is INTERNAL_ERROR, not a routine cancellation: CANCELLED is 0x1.
| Code Name | Value | Description |
|---|---|---|
moqt.NoError |
0x0 | Normal termination |
moqt.InternalSessionErrorCode |
0x1 | Internal error |
moqt.UnauthorizedSessionErrorCode |
0x2 | Authentication/authorization |
moqt.ProtocolViolationErrorCode |
0x3 | Protocol violation |
moqt.KeyValueFormattingErrorCode |
0x6 | A malformed or repeated key-value pair |
moqt.GoAwayTimeoutErrorCode |
0x10 | GoAway timeout |
moqt.ControlMessageTimeoutErrorCode |
0x11 | The peer took too long to answer a control message |
moqt.VersionNegotiationFailedErrorCode |
0x15 | No version could be negotiated |
moqt.NotSupportedErrorCode |
0x40 | Tokens are not verified on an Auth Stream (gomoqt) |
| Code Name | Value | Description |
|---|---|---|
moqt.AnnounceErrorCodeInternal |
0x0 | Internal error |
moqt.UninterestedErrorCode |
0x1 | Uninterested (CANCELLED) |
moqt.AnnounceErrorCodeUnauthorized |
0x40 | Prefix outside the root of every grant (gomoqt) |
moqt.AnnounceErrorCodeInvalidPrefix |
0x43 | Invalid prefix (gomoqt) |
moqt.BannedPrefixErrorCode |
0x44 | Banned prefix (gomoqt) |
A malformed or out-of-order announcement (an unknown Announce ID, a second ANNOUNCE_START for a route, a repeated Hop ID) is a protocol violation that closes the session, not a stream reset.
| Code Name | Value | Description |
|---|---|---|
moqt.SubscribeErrorCodeInternal |
0x0 | Internal error |
moqt.SubscribeErrorCodeCanceled |
0x1 | Cancelled by the subscriber |
moqt.SubscribeErrorCodeTimeout |
0x31 | The peer never answered (CONTROL_TIMEOUT) |
moqt.SubscribeErrorCodeNotFound |
0x33 | Track not found (NOT_FOUND) |
moqt.SubscribeErrorCodeUnroutable |
0x36 | The only source runs through the subscriber (UNROUTABLE) |
moqt.SubscribeErrorCodeUnauthorized |
0x40 | Unauthorized (gomoqt) |
moqt.SubscribeErrorCodeInvalidRange |
0x41 | A peer’s range broke a moq-lite rule, such as a Frame End without a Group End (gomoqt) |
moqt.SubscribeErrorCodeDuplicateID |
0x42 | Duplicate subscribe ID (gomoqt) |
| Code Name | Value | Description |
|---|---|---|
moqt.InternalGroupErrorCode |
0x0 | Internal error |
moqt.SubscribeCanceledErrorCode |
0x1 | Cancelled by either end |
moqt.ExpiredGroupErrorCode |
0x2 | Aged out of the subscriber’s Max Age (DELIVERY_TIMEOUT) |
moqt.ClosedSessionGroupErrorCode |
0x3 | The session is closing |
moqt.GroupTooLargeErrorCode |
0x32 | Past the publisher’s cache budget |
moqt.NotFoundGroupErrorCode |
0x33 | The group was never here |
moqt.OldGroupErrorCode |
0x34 | Superseded by a newer group and dropped |
moqt.EvictedGroupErrorCode |
0x35 | Dropped under memory pressure while current |
moqt.FrameTooLargeErrorCode |
0x38 | A frame larger than the receiver accepts |
moqt.UnauthorizedGroupErrorCode |
0x40 | Outside the session’s scope, as for a refused fetch (gomoqt) |
moqt.InvalidRangeGroupErrorCode |
0x41 | A peer’s FETCH frame range broke a moq-lite rule (gomoqt) |
| Code Name | Value | Description |
|---|---|---|
moqt.FetchErrorCodeInternal |
0x0 | Internal error |
moqt.FetchErrorCodeTimeout |
0x31 | Fetch timeout (CONTROL_TIMEOUT) |
A fetch’s answer is the group itself, so a publisher that refuses a fetch resets the group: the refusal is a *moqt.GroupError from GroupReader.ReadFrame, such as UnauthorizedGroupErrorCode.
| Code Name | Value | Description |
|---|---|---|
moqt.ProbeErrorCodeInternal |
0x0 | Internal error |
moqt.ProbeErrorCodeTimeout |
0x31 | Probe timeout (CONTROL_TIMEOUT) |
moqt.ProbeErrorCodeNotSupported |
0x45 | Probe not supported (gomoqt) |
Error Handling
Section titled “Error Handling”Implementations in gomoqt/moqt return specific error types for different error scenarios. You can use type assertions to handle these errors accordingly.
- Example: When
moqt.TrackWriterreturns an error
var subErr *moqt.SubscribeError if errors.As(err, &subErr) { // Handle SubscribeError }Error Propagation
Section titled “Error Propagation”You can get context.Context via Context method implementated in gomoqt/moqt such as moqt.TrackReader or moqt.Session.
moqt.Cause function is provided to access to the root cause of an error propagation and to parse the cause as a MoQ error if it is a QUIC error.
This is because the context.Context holds the original QUIC error and context.Cause returns the cause as is.
func Cause(ctx context.Context) errorExample: Get MoQ cause from context.Context
var ctx context.Context
var cause error cause = moqt.Cause(ctx)To get the MoQ cause from a context, use errors.As function with corresponding error type.
Example: When moqt.TrackWriter’s context is canceled
var tw *moqt.TrackWriter ctx := tw.Context()
if err := moqt.Cause(ctx); err != nil { var subErr *moqt.SubscribeError if errors.As(err, &subErr) { // Handle SubscribeError }
var sessErr *moqt.SessionError if errors.As(err, &sessErr) { // Handle SessionError } }