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
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:
parent
7cc11af378
commit
98fda3b404
2 changed files with 3 additions and 26 deletions
|
@ -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
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue