errors

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DocumentError

type DocumentError struct {
	// contains filtered or unexported fields
}

DocumentError contains methods for forming a detailed description of the error for a person. The resulting message will contain the filename, line number, and where the error occurred.

func NewDocumentError

func NewDocumentError(file *fs.File, err Err) DocumentError

func (DocumentError) Code

func (e DocumentError) Code() ErrorCode

func (DocumentError) Column

func (e DocumentError) Column() uint

func (DocumentError) ErrCode

func (e DocumentError) ErrCode() int

func (DocumentError) Error

func (e DocumentError) Error() string

func (DocumentError) Filename

func (e DocumentError) Filename() string

func (DocumentError) IncorrectUserType

func (e DocumentError) IncorrectUserType() string

func (DocumentError) Index

func (e DocumentError) Index() bytes.Index

func (DocumentError) Line

func (e DocumentError) Line() uint

Line returns 0 if the line number cannot be determined, or 1+ if it can.

func (DocumentError) Message

func (e DocumentError) Message() string

func (DocumentError) Position

func (e DocumentError) Position() uint

func (*DocumentError) SetFile

func (e *DocumentError) SetFile(file *fs.File)

func (*DocumentError) SetIncorrectUserType

func (e *DocumentError) SetIncorrectUserType(s string)

func (*DocumentError) SetIndex

func (e *DocumentError) SetIndex(index bytes.Index)

func (*DocumentError) SetMessage

func (e *DocumentError) SetMessage(message string)

func (*DocumentError) SourceSubString

func (e *DocumentError) SourceSubString() string

SourceSubString returns empty string, if cannot determine the source sub-string.

func (*DocumentError) String

func (e *DocumentError) String() string

type Err

type Err interface {
	error

	Code() ErrorCode
}

type Error

type Error interface {
	Filename() string
	Position() uint
	Line() uint
	Column() uint
	Message() string
	ErrCode() int
	IncorrectUserType() string
}

type ErrorCode

type ErrorCode int //nolint:errname // This is okay.
const (
	ErrGeneric    ErrorCode = 0
	ErrImpossible ErrorCode = 1

	ErrUserTypeFound             ErrorCode = 101
	ErrUnknownType               ErrorCode = 102
	ErrUnknownJSchemaType        ErrorCode = 103
	ErrInfinityRecursionDetected ErrorCode = 104
	ErrNodeTypeCantBeGuessed     ErrorCode = 105

	ErrValidator                       ErrorCode = 201
	ErrEmptySchema                     ErrorCode = 202
	ErrEmptyJson                       ErrorCode = 203
	ErrOrRuleSetValidation             ErrorCode = 204
	ErrRequiredKeyNotFound             ErrorCode = 205
	ErrSchemaDoesNotSupportKey         ErrorCode = 206
	ErrUnexpectedLexInLiteralValidator ErrorCode = 207
	ErrUnexpectedLexInObjectValidator  ErrorCode = 208
	ErrUnexpectedLexInArrayValidator   ErrorCode = 209
	ErrInvalidValueType                ErrorCode = 210
	ErrInvalidKeyType                  ErrorCode = 211
	ErrUnexpectedLexInMixedValidator   ErrorCode = 212
	ErrObjectExpected                  ErrorCode = 213
	ErrPropertyNotFound                ErrorCode = 214

	ErrInvalidCharacter                      ErrorCode = 301
	ErrInvalidCharacterInAnnotationObjectKey ErrorCode = 302
	ErrUnexpectedEOF                         ErrorCode = 303
	ErrAnnotationNotAllowed                  ErrorCode = 304

	ErrNodeGrow                 ErrorCode = 401
	ErrDuplicateKeysInSchema    ErrorCode = 402
	ErrDuplicationOfNameOfTypes ErrorCode = 403

	ErrDuplicateRule ErrorCode = 501

	ErrUnknownRule                                 ErrorCode = 601
	ErrConstraintValidation                        ErrorCode = 602
	ErrConstraintStringLengthValidation            ErrorCode = 603
	ErrInvalidValueOfConstraint                    ErrorCode = 604
	ErrZeroPrecision                               ErrorCode = 605
	ErrEmptyEmail                                  ErrorCode = 606
	ErrInvalidEmail                                ErrorCode = 607
	ErrConstraintMinItemsValidation                ErrorCode = 608
	ErrConstraintMaxItemsValidation                ErrorCode = 609
	ErrDoesNotMatchAnyOfTheEnumValues              ErrorCode = 610
	ErrDoesNotMatchRegularExpression               ErrorCode = 611
	ErrInvalidUri                                  ErrorCode = 612
	ErrInvalidDateTime                             ErrorCode = 613
	ErrInvalidUuid                                 ErrorCode = 614
	ErrInvalidConst                                ErrorCode = 615
	ErrInvalidDate                                 ErrorCode = 616
	ErrValueOfOneConstraintGreaterThanAnother      ErrorCode = 617
	ErrValueOfOneConstraintGreaterOrEqualToAnother ErrorCode = 618

	ErrInvalidSchemaName                ErrorCode = 701
	ErrInvalidSchemaNameInAllOfRule     ErrorCode = 702
	ErrUnacceptableRecursionInAllOfRule ErrorCode = 703
	ErrUnacceptableUserTypeInAllOfRule  ErrorCode = 704
	ErrConflictAdditionalProperties     ErrorCode = 705

	ErrLoader                           ErrorCode = 801
	ErrIncorrectRuleValueType           ErrorCode = 802
	ErrIncorrectRuleWithoutExample      ErrorCode = 803
	ErrIncorrectRuleForSeveralNode      ErrorCode = 804
	ErrLiteralValueExpected             ErrorCode = 805
	ErrInvalidValueInEnumRule           ErrorCode = 806
	ErrIncorrectArrayItemTypeInEnumRule ErrorCode = 807
	ErrUnacceptableValueInAllOfRule     ErrorCode = 808
	ErrTypeNameNotFoundInAllOfRule      ErrorCode = 809
	ErrDuplicationInEnumRule            ErrorCode = 810

	ErrArrayWasExpectedInOrRule       ErrorCode = 901
	ErrEmptyArrayInOrRule             ErrorCode = 902
	ErrOneElementInArrayInOrRule      ErrorCode = 903
	ErrIncorrectArrayItemTypeInOrRule ErrorCode = 904
	ErrEmptyRuleSet                   ErrorCode = 905

	ErrRuleOptionalAppliesOnlyToObjectProperties ErrorCode = 1101
	ErrCannotSpecifyOtherRulesWithTypeReference  ErrorCode = 1102
	ErrShouldBeNoOtherRulesInSetWithOr           ErrorCode = 1103
	ErrShouldBeNoOtherRulesInSetWithEnum         ErrorCode = 1104
	ErrShouldBeNoOtherRulesInSetWithAny          ErrorCode = 1105
	ErrInvalidNestedElementsFoundForTypeAny      ErrorCode = 1106
	ErrInvalidChildNodeTogetherWithTypeReference ErrorCode = 1107
	ErrInvalidChildNodeTogetherWithOrRule        ErrorCode = 1108
	ErrConstraintMinNotFound                     ErrorCode = 1109
	ErrConstraintMaxNotFound                     ErrorCode = 1110
	ErrInvalidValueInTheTypeRule                 ErrorCode = 1111
	ErrNotFoundRulePrecision                     ErrorCode = 1112
	ErrNotFoundRuleEnum                          ErrorCode = 1113
	ErrNotFoundRuleOr                            ErrorCode = 1114
	ErrIncompatibleTypes                         ErrorCode = 1115

	ErrUnexpectedConstraint ErrorCode = 1117

	ErrChecker                               ErrorCode = 1201
	ErrElementNotFoundInArray                ErrorCode = 1203
	ErrIncorrectConstraintValueForEmptyArray ErrorCode = 1204

	ErrIncorrectUserType                              ErrorCode = 1301
	ErrTypeNotFound                                   ErrorCode = 1302
	ErrImpossibleToDetermineTheJsonTypeDueToRecursion ErrorCode = 1303
	ErrInvalidKeyShortcutType                         ErrorCode = 1304

	ErrEmptyType                          ErrorCode = 1401
	ErrUnnecessaryLexemeAfterTheEndOfEnum ErrorCode = 1402

	ErrRegexUnexpectedStart ErrorCode = 1500
	ErrRegexUnexpectedEnd   ErrorCode = 1501
	ErrRegexInvalid         ErrorCode = 1502

	ErrEnumArrayExpected  ErrorCode = 1600
	ErrEnumIsHoldRuleName ErrorCode = 1601
	ErrEnumRuleNotFound   ErrorCode = 1602
	ErrNotAnEnumRule      ErrorCode = 1603
)

func (ErrorCode) Code

func (c ErrorCode) Code() ErrorCode

func (ErrorCode) Error

func (c ErrorCode) Error() string

func (ErrorCode) Itoa

func (c ErrorCode) Itoa() string

type Errorf

type Errorf struct {
	// contains filtered or unexported fields
}

func Format

func Format(code ErrorCode, args ...interface{}) Errorf

func (Errorf) Code

func (e Errorf) Code() ErrorCode

func (Errorf) Error

func (e Errorf) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL