Skip to content

Commit

Permalink
Use stringer for "enums"
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi committed Mar 6, 2023
1 parent a0cd2e5 commit a4a716a
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/types/document_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ import (
"github.com/FerretDB/FerretDB/internal/util/must"
)

//go:generate ../../bin/stringer -linecomment -type ValidationErrorCode

// ValidationErrorCode represents ValidationData error code.
type ValidationErrorCode int

const (
_ ValidationErrorCode = iota

// ErrValidation indicates that document is invalid.
ErrValidation ValidationErrorCode = iota + 1
ErrValidation

// ErrWrongIDType indicates that _id field is invalid.
ErrWrongIDType
Expand Down
29 changes: 29 additions & 0 deletions internal/types/documentpatherrorcode_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion internal/types/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,29 @@ import (
"github.com/FerretDB/FerretDB/internal/util/must"
)

//go:generate ../../bin/stringer -linecomment -type DocumentPathErrorCode

// DocumentPathErrorCode represents DocumentPathError error code.
type DocumentPathErrorCode int

const (
_ DocumentPathErrorCode = iota

// ErrDocumentPathKeyNotFound indicates that key was not found in document.
ErrDocumentPathKeyNotFound = iota + 1
ErrDocumentPathKeyNotFound

// ErrDocumentPathCannotAccess indicates that path couldn't be accessed.
ErrDocumentPathCannotAccess

// ErrDocumentPathArrayInvalidIndex indicates that provided array index is invalid.
ErrDocumentPathArrayInvalidIndex

// ErrDocumentPathIndexOutOfBound indicates that provided array index is out of bound.
ErrDocumentPathIndexOutOfBound

// ErrDocumentPathCannotCreateField indicates that it's impossible to create a specific field.
ErrDocumentPathCannotCreateField

// ErrDocumentPathEmptyKey indicates that provided path contains empty key.
ErrDocumentPathEmptyKey
)
Expand Down
26 changes: 26 additions & 0 deletions internal/types/validationerrorcode_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a4a716a

Please sign in to comment.