@@ -5,22 +5,22 @@ import (
55 "fmt"
66)
77
8- // Common errors
8+ // Common errors.
99var (
10- // ErrDataNotFound indicates that the tokenizer data files could not be found
10+ // ErrDataNotFound indicates that the tokenizer data files could not be found.
1111 ErrDataNotFound = errors .New ("tokenizer data not found" )
1212
13- // ErrInvalidToken indicates an invalid token was provided
13+ // ErrInvalidToken indicates an invalid token was provided.
1414 ErrInvalidToken = errors .New ("invalid token" )
1515
16- // ErrTokenNotFound indicates a token was not found in the vocabulary
16+ // ErrTokenNotFound indicates a token was not found in the vocabulary.
1717 ErrTokenNotFound = errors .New ("token not found" )
1818
19- // ErrInvalidTokenID indicates an invalid token ID was provided
19+ // ErrInvalidTokenID indicates an invalid token ID was provided.
2020 ErrInvalidTokenID = errors .New ("invalid token ID" )
2121)
2222
23- // DataError represents an error related to tokenizer data loading or processing
23+ // DataError represents an error related to tokenizer data loading or processing.
2424type DataError struct {
2525 Op string // Operation that failed
2626 Path string // File path if applicable
@@ -38,7 +38,7 @@ func (e *DataError) Unwrap() error {
3838 return e .Err
3939}
4040
41- // TokenError represents an error related to token operations
41+ // TokenError represents an error related to token operations.
4242type TokenError struct {
4343 Token string // The token that caused the error
4444 TokenID int // The token ID if applicable
@@ -60,7 +60,7 @@ func (e *TokenError) Unwrap() error {
6060 return e .Err
6161}
6262
63- // ConfigError represents an error in tokenizer configuration
63+ // ConfigError represents an error in tokenizer configuration.
6464type ConfigError struct {
6565 Field string // Configuration field that has an error
6666 Value any // The invalid value
@@ -77,22 +77,22 @@ func (e *ConfigError) Unwrap() error {
7777
7878// Helper functions for creating errors
7979
80- // NewDataError creates a new DataError
80+ // NewDataError creates a new DataError.
8181func NewDataError (op , path string , err error ) error {
8282 return & DataError {Op : op , Path : path , Err : err }
8383}
8484
85- // NewTokenError creates a new TokenError
85+ // NewTokenError creates a new TokenError.
8686func NewTokenError (op , token string , err error ) error {
8787 return & TokenError {Op : op , Token : token , Err : err }
8888}
8989
90- // NewTokenIDError creates a new TokenError with a token ID
90+ // NewTokenIDError creates a new TokenError with a token ID.
9191func NewTokenIDError (op string , tokenID int , err error ) error {
9292 return & TokenError {Op : op , TokenID : tokenID , Err : err }
9393}
9494
95- // NewConfigError creates a new ConfigError
95+ // NewConfigError creates a new ConfigError.
9696func NewConfigError (field string , value any , err error ) error {
9797 return & ConfigError {Field : field , Value : value , Err : err }
9898}
0 commit comments