refactor(deadcode): unused custom errors
All checks were successful
Pull-Request / tests (pull_request) Successful in 1m9s
Pull-Request / static-analysis (pull_request) Successful in 1m38s
Pull-Request / post-run (pull_request) Successful in 30s
Push / pre-run (push) Successful in 26s
Push / tests (push) Successful in 1m4s
Push / static-analysis (push) Successful in 1m28s
Push / post-run (push) Successful in 40s

This commit is contained in:
Marc 2024-11-13 23:59:55 -05:00
parent 7cc11af378
commit 98fda3b404
Signed by: marc
GPG key ID: 048E042F22B5DC79
2 changed files with 3 additions and 26 deletions

View file

@ -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
}

View file

@ -5,6 +5,7 @@
package service_definition package service_definition
import ( import (
"fmt"
"github.com/goccy/go-yaml" "github.com/goccy/go-yaml"
"os" "os"
) )
@ -22,11 +23,11 @@ func (f FileDefinitionFetcher) GetDefinition(path string) (ServiceDefinition, er
defData, err := os.ReadFile(path) defData, err := os.ReadFile(path)
if err != nil { 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 { 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 return definition, nil