From 98fda3b404b96e5e80ab06f7001ab8bf2c3e06a4 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Wed, 13 Nov 2024 23:59:55 -0500 Subject: [PATCH] refactor(deadcode): unused custom errors --- service_definition/errors.go | 24 ------------------- service_definition/file_definition_fetcher.go | 5 ++-- 2 files changed, 3 insertions(+), 26 deletions(-) delete mode 100644 service_definition/errors.go diff --git a/service_definition/errors.go b/service_definition/errors.go deleted file mode 100644 index 45fa4a1..0000000 --- a/service_definition/errors.go +++ /dev/null @@ -1,24 +0,0 @@ -package service_definition - -type FileDoesNotExistError struct { - Message string - ExpectedPath string -} - -func (r *FileDoesNotExistError) Error() string { - prefix := "File not found" - - if r.Message != "" { - prefix = r.Message - } - - return prefix + ": " + r.ExpectedPath -} - -type InvalidServiceDefinitionError struct { - Path string -} - -func (r *InvalidServiceDefinitionError) Error() string { - return "Service definition does not satisfy expected schema: " + r.Path -} diff --git a/service_definition/file_definition_fetcher.go b/service_definition/file_definition_fetcher.go index 00c78ee..15c3328 100644 --- a/service_definition/file_definition_fetcher.go +++ b/service_definition/file_definition_fetcher.go @@ -5,6 +5,7 @@ package service_definition import ( + "fmt" "github.com/goccy/go-yaml" "os" ) @@ -22,11 +23,11 @@ func (f FileDefinitionFetcher) GetDefinition(path string) (ServiceDefinition, er defData, err := os.ReadFile(path) if err != nil { - return ServiceDefinition{}, &FileDoesNotExistError{Message: "Could not find service configuration file", ExpectedPath: path} + return ServiceDefinition{}, fmt.Errorf("Could not find service configuration file: %s", path) } if err = yaml.Unmarshal(defData, &definition); err != nil { - return ServiceDefinition{}, &InvalidServiceDefinitionError{Path: path} + return ServiceDefinition{}, fmt.Errorf("Service definition does not satisfy expected schema: %s", path) } return definition, nil