restructure package. Change label extraction strategy.

This commit is contained in:
Jay
2026-05-08 09:58:04 -04:00
parent 8857028017
commit 622f66e376
11 changed files with 164 additions and 186 deletions
+33
View File
@@ -0,0 +1,33 @@
// Package errors defines standard error types used throughout the roots-ws library.
package envelope
import (
"errors"
)
var (
// Data Structure Errors
// ErrInvalidJSON indicates that a byte sequence could not be parsed as valid JSON.
// This is typically returned when unmarshaling fails during envelope processing.
ErrInvalidJSON = errors.New("invalid JSON")
// ErrMissingField indicates that a required field is absent from a data structure.
// This is returned when validating that all mandatory components are present.
ErrMissingField = errors.New("missing required field")
// ErrWrongFieldType indicates that a field's type does not match the expected type.
// This is returned when unmarshaling a specific value fails due to type mismatch.
ErrWrongFieldType = errors.New("wrong field type")
// Envelope Errors
// ErrInvalidEnvelope indicates that a message does not conform to the Nostr envelope structure.
// This typically occurs when an array has incorrect number of elements for its message type.
ErrInvalidEnvelope = errors.New("invalid envelope format")
// ErrWrongEnvelopeLabel indicates that an envelope's label does not match the expected type.
// This is returned when attempting to parse an envelope using a Find function that
// expects a different label than what was provided.
ErrWrongEnvelopeLabel = errors.New("wrong envelope label")
)