gitlab.com/evatix-go/core@v1.3.55/internal/internalinterface/all-errors-related.go (about)

     1  package internalinterface
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  type IsReferencesEmptyChecker interface {
     8  	IsReferencesEmpty() bool
     9  }
    10  
    11  type HasReferencesChecker interface {
    12  	HasReferences() bool
    13  }
    14  
    15  type StringCompiler interface {
    16  	Compile() string
    17  }
    18  
    19  type HasCurrentErrorChecker interface {
    20  	HasCurrentError() bool
    21  }
    22  
    23  type FullStringer interface {
    24  	FullString() string
    25  }
    26  
    27  type TypeNamer interface {
    28  	TypeName() string
    29  }
    30  
    31  type IsNullOrAnyNullChecker interface {
    32  	IsNull() bool
    33  	IsAnyNull() bool
    34  }
    35  
    36  type CodeTypeNamer interface {
    37  	CodeTypeName() string
    38  }
    39  
    40  type TypeCodeNameStringer interface {
    41  	TypeCodeNameString() string
    42  }
    43  
    44  // SerializeWithoutTracesGetter
    45  //
    46  //  Stack traces will be SKIPPED from the json bytes
    47  type SerializeWithoutTracesGetter interface {
    48  	SerializeWithoutTraces() ([]byte, error)
    49  }
    50  
    51  type FullOrErrorMessageGetter interface {
    52  	FullOrErrorMessage(
    53  		isErrorMessage,
    54  		isWithRef bool,
    55  	) string
    56  }
    57  
    58  type ReferencesCompiledStringGetter interface {
    59  	ReferencesCompiledString() string
    60  }
    61  
    62  type ErrorStringGetter interface {
    63  	ErrorString() string
    64  }
    65  
    66  type BaseErrorOrCollectionWrapper interface {
    67  	ErrorHandler
    68  	IsNullOrAnyNullChecker
    69  	HasErrorChecker
    70  	IsEmptyChecker
    71  	ErrorStringGetter
    72  	IsSuccessValidator
    73  	IsInvalidChecker
    74  	HasErrorOrHasAnyErrorChecker
    75  	HasAnyIssues() bool
    76  	IsDefined() bool
    77  
    78  	// StringCompiler
    79  	//
    80  	//  error wrapper compiles to string with traces.
    81  	StringCompiler
    82  	ErrorHandler
    83  	ErrorMessageHandler
    84  
    85  	FullStringer
    86  	CompiledErrorGetter
    87  	FullStringWithTracesGetter
    88  	FullStringWithTracesIfGetter
    89  	ReferencesCompiledStringGetter
    90  	CompiledErrorWithStackTracesGetter
    91  	CompiledStackTracesStringGetter
    92  
    93  	CompiledJsonErrorWithStackTracesGetter
    94  	CompiledJsonStringWithStackTracesGetter
    95  
    96  	FullStringSplitByNewLine() []string
    97  	FullStringWithoutReferences() string
    98  
    99  	MustBeEmptyError()
   100  	MustBeSafe()
   101  
   102  	// SerializeWithoutTracesGetter
   103  	//
   104  	//  Stack traces will be SKIPPED from the json bytes
   105  	SerializeWithoutTracesGetter
   106  	// Serialize
   107  	//
   108  	//  Should include stack traces
   109  	Serialize() ([]byte, error)
   110  	SerializeMust() []byte
   111  	MarshalJSON() ([]byte, error)
   112  	UnmarshalJSON(data []byte) error
   113  	ErrorValueGetter
   114  
   115  	Dispose()
   116  
   117  	CompiledVoidLogger
   118  	IsCollectionTyper
   119  
   120  	ReflectSetTo(toPtr interface{}) error
   121  
   122  	fmt.Stringer
   123  }
   124  
   125  // IsCollectionTyper
   126  //
   127  //   returns true if current type is collection
   128  type IsCollectionTyper interface {
   129  	// IsCollectionType
   130  	//
   131  	//  returns true if current type is collection
   132  	IsCollectionType() bool
   133  }
   134  
   135  // BasicErrWrapper
   136  //
   137  // IsEmpty:
   138  //  Refers to no error for print or doesn't treat this as error.
   139  //
   140  //  Conditions (true):
   141  //      - if Wrapper nil, Or,
   142  //      - if Wrapper is StaticEmptyPtr, Or,
   143  //      - if Wrapper .errorType is IsNoError(), Or,
   144  //      - if Wrapper .currentError NOT nil and Wrapper .references.IsEmpty()
   145  type BasicErrWrapper interface {
   146  	BaseErrorOrCollectionWrapper
   147  	IsReferencesEmptyChecker
   148  	HasReferencesChecker
   149  	IsEmptyErrorChecker
   150  	HasCurrentErrorChecker
   151  
   152  	TypeNameCodeMessage() string
   153  	TypeNameWithCustomMessage(customMessage string) string
   154  	RawErrorTypeValue() uint16
   155  	TypeNamer
   156  	CodeTypeNamer
   157  	TypeCodeNameStringer
   158  
   159  	IsErrorMessageEqual(msg string) bool
   160  	// IsErrorMessage
   161  	//
   162  	// If error IsEmpty then returns false regardless
   163  	IsErrorMessage(msg string, isCaseSensitive bool) bool
   164  	ErrorValueGetter
   165  	StringIf(isWithRef bool) string
   166  
   167  	FullOrErrorMessageGetter
   168  	JsonModelAnyGetter
   169  	MarshalJSON() ([]byte, error)
   170  	UnmarshalJSON(data []byte) error
   171  
   172  	IsErrorEqualsChecker
   173  }
   174  
   175  type AddErrorer interface {
   176  	AddError(err error)
   177  }
   178  
   179  type IsErrorsCollected interface {
   180  	IsErrorsCollected(errorsItems ...error) bool
   181  }
   182  
   183  type BaseRawErrCollectionDefiner interface {
   184  	BaseErrorOrCollectionWrapper
   185  	Add(err error)
   186  	AddMessages(messages ...string)
   187  	AddMsg(message string)
   188  	AddErrorWithMessage(err error, message string)
   189  	AddErrorWithMessageRef(err error, message string, reference interface{})
   190  	Fmt(format string, v ...interface{})
   191  	FmtIf(isAdd bool, format string, v ...interface{})
   192  	References(message string, v ...interface{})
   193  	AddErrorer
   194  	IsErrorsCollected
   195  	AddWithTraceRef(
   196  		err error,
   197  		traces []string,
   198  		referenceItem interface{},
   199  	)
   200  	AddWithCompiledTraceRef(
   201  		err error,
   202  		compiledTrace string,
   203  		referenceItem interface{},
   204  	)
   205  	AddWithRef(
   206  		err error,
   207  		referenceItem interface{},
   208  	)
   209  	AddManyErrorer
   210  	ConditionalErrorAdder
   211  	// AddString
   212  	//
   213  	//  Empty string will be ignored
   214  	AddString(
   215  		message string,
   216  	)
   217  	AddStringSliceAsErr(
   218  		errSliceStrings ...string,
   219  	)
   220  	CommonSliceDefiner
   221  	StringUsingJoiner
   222  	StringUsingJoinerAdditional(joiner, additionalMessage string) string
   223  	CompiledErrorGetter
   224  	CompiledErrorUsingJoiner(joiner string) error
   225  	CompiledErrorUsingJoinerAdditionalMessage(joiner, additionalMessage string) error
   226  	CompiledErrorUsingStackTraces(joiner string, stackTraces []string) error
   227  	StringWithAdditionalMessage(additionalMessage string) string
   228  }
   229  
   230  type DyanmicLinqer interface {
   231  	FirstDynamic() interface{}
   232  	LastDynamic() interface{}
   233  	FirstOrDefaultError() error
   234  	FirstOrDefaultFullMessage() string
   235  	LastOrDefaultCompiledError() error
   236  	LastOrDefaultError() error
   237  	LastOrDefaultFullMessage() string
   238  	FirstOrDefaultDynamic() interface{}
   239  	LastOrDefaultDynamic() interface{}
   240  	SkipDynamic(skippingItemsCount int) interface{}
   241  	TakeDynamic(takeDynamicItems int) interface{}
   242  	LimitDynamic(limit int) interface{}
   243  }
   244  
   245  type AddManyErrorer interface {
   246  	// AddErrors no error then skip adding
   247  	AddErrors(errs ...error)
   248  }
   249  
   250  type AddManyPointerErrorer interface {
   251  	// AddErrorsPtr no error then skip adding
   252  	AddErrorsPtr(errs *[]error)
   253  }
   254  
   255  type ConditionalErrorAdder interface {
   256  	// ConditionalAddError adds error if isAdd and error not nil.
   257  	ConditionalAddError(
   258  		isAdd bool,
   259  		err error,
   260  	)
   261  }
   262  
   263  type BaseErrorWrapperCollectionDefiner interface {
   264  	BaseErrorOrCollectionWrapper
   265  	DyanmicLinqer
   266  	CommonSliceDefiner
   267  	LastIndex() int
   268  	HasIndex(index int) bool
   269  
   270  	AddErrorer
   271  	AddManyErrorer
   272  	AddManyPointerErrorer
   273  	ConditionalErrorAdder
   274  
   275  	HasError() bool
   276  	IsEmpty() bool
   277  	Length() int
   278  
   279  	ToString(
   280  		isIncludeStakeTraces,
   281  		isIncludeHeader bool,
   282  	) string
   283  	ToStrings(
   284  		isIncludeStakeTraces,
   285  		isIncludeHeader bool,
   286  	) []string
   287  
   288  	Strings(isIncludeStakeTraces bool) []string
   289  
   290  	String() string
   291  	StringIf(isIncludeTraces bool) string
   292  	StringStackTracesWithoutHeader() string
   293  	DisplayStringWithTraces() string
   294  
   295  	DisplayStringWithLimitTraces(limit int) string
   296  	LogDisplayStringWithLimitTraces(limit int)
   297  	FullStringWithTracesIfGetter
   298  
   299  	StringWithoutHeader() string
   300  	StringsWithoutHeader() []string
   301  
   302  	LinesIf(
   303  		isIncludeReferences bool,
   304  	) []string
   305  
   306  	StringsWithoutReferencePlusHeader() []string
   307  	StringsIf(isIncludeStakeTraces bool) []string
   308  
   309  	FullStrings() []string
   310  	FullStringsWithTraces() []string
   311  	FullStringsWithLimitTraces(limit int) []string
   312  
   313  	Errors() []error
   314  	CompiledErrors() []error
   315  	CompiledErrorsWithStackTraces() []error
   316  
   317  	GetAsError() error
   318  
   319  	// HandleWithMsg Skip if no error.
   320  	HandleWithMsg(msg string)
   321  }