diff --git a/api.go b/api.go index f77f1c7e54750960b6c82e0471fabc69afef5b90..161586651bf913dfce341814cab84a8a8256b23c 100644 --- a/api.go +++ b/api.go @@ -37,16 +37,6 @@ func (s *setting[C]) SetMnemonic(mnemonic string) *setting[C] { return s } -// Check if the setting contains errors -func (s *setting[C]) HasErrors() bool { - return len(s.errors) > 0 -} - -// Get all errors -func (s *setting[C]) Errors() []error { - return s.errors -} - // Config() returns the configuration func (s *setting[C]) Config() C { return s.config diff --git a/error.go b/error.go index a6c93fe578f2f5e10ee16a89ac282802037fa84a..667c886070b46ed431dfd3b052eb1a262587fb6e 100644 --- a/error.go +++ b/error.go @@ -5,6 +5,23 @@ import ( "reflect" ) +// ResetError is used to reset the error to nil +// After calling this function, the call HasErrors() will return false +func (s *setting[C]) ResetErrors() *setting[C] { + s.errors = []error{} + return s +} + +// Check if the setting contains errors +func (s *setting[C]) HasErrors() bool { + return len(s.errors) > 0 +} + +// Get all errors +func (s *setting[C]) Errors() []error { + return s.errors +} + var FileNameEmptyError = errors.New("file name is empty") var MnemonicEmptyError = errors.New("mnemonic is empty") var NoFileImportedError = errors.New("no file imported") @@ -49,13 +66,6 @@ func newUnsupportedTypeError(t reflect.Type) UnsupportedTypeError { return UnsupportedTypeError(errors.New("type " + t.String() + " is not supported")) } -// ResetError is used to reset the error to nil -// After calling this function, the call HasErrors() will return false -func (s *setting[C]) ResetErrors() *setting[C] { - s.errors = []error{} - return s -} - // At the reflect level, some types are not supported type UnsupportedReflectKindError error diff --git a/error_test.go b/error_test.go index 0e58e86c4e71d60b44801920c1522c07c8ee2db2..e6c022bb2b183f43efc0b3d8944576b00bf5cbc0 100644 --- a/error_test.go +++ b/error_test.go @@ -19,6 +19,8 @@ func TestResetErrors(t *testing.T) { assert.True(t, c.HasErrors()) c.ResetErrors() assert.False(t, c.HasErrors()) + + assert.Empty(t, c.Errors()) } func TestNewFlagDoesNotExistError(t *testing.T) {