Clean up error messages
This commit is contained in:
parent
95fea5ef30
commit
8b9844465c
2
job.go
2
job.go
@ -96,7 +96,7 @@ func (j Job) Validate() error {
|
||||
}
|
||||
|
||||
if _, err := cron.ParseStandard(j.Schedule); err != nil {
|
||||
return fmt.Errorf("job %s has an invalid schedule: %v: %w", j.Name, err, ErrInvalidConfigValue)
|
||||
return fmt.Errorf("job %s has an invalid schedule: %w: %w", j.Name, err, ErrInvalidConfigValue)
|
||||
}
|
||||
|
||||
if j.Config == nil {
|
||||
|
@ -69,7 +69,7 @@ func RunHTTPHandlers(addr string) error {
|
||||
http.HandleFunc("/health", healthHandleFunc)
|
||||
http.Handle("/metrics", promhttp.Handler())
|
||||
|
||||
return fmt.Errorf("error on healthcheck: %w", http.ListenAndServe(addr, nil)) //#nosec: g114
|
||||
return fmt.Errorf("error on http server: %w", http.ListenAndServe(addr, nil)) //#nosec: g114
|
||||
}
|
||||
|
||||
func ScheduleAndRunJobs(jobs []Job) error {
|
||||
|
22
tasks.go
22
tasks.go
@ -89,11 +89,16 @@ func (t JobTaskMySQL) Validate() error {
|
||||
return fmt.Errorf("task %s is missing dump_to path: %w", t.Name, ErrMissingField)
|
||||
}
|
||||
|
||||
if s, err := os.Stat(t.DumpToPath); err != nil {
|
||||
if stat, err := os.Stat(t.DumpToPath); err != nil {
|
||||
if !errors.Is(err, fs.ErrNotExist) {
|
||||
return fmt.Errorf("task %s: invalid dump_to: could not stat path: %v: %w", t.Name, err, ErrInvalidConfigValue)
|
||||
return fmt.Errorf(
|
||||
"task %s: invalid dump_to: could not stat path: %s: %w",
|
||||
t.Name,
|
||||
t.DumpToPath,
|
||||
ErrInvalidConfigValue,
|
||||
)
|
||||
}
|
||||
} else if s.Mode().IsDir() {
|
||||
} else if stat.Mode().IsDir() {
|
||||
return fmt.Errorf("task %s: dump_to cannot be a directory: %w", t.Name, ErrInvalidConfigValue)
|
||||
}
|
||||
|
||||
@ -190,11 +195,16 @@ func (t JobTaskSqlite) Validate() error {
|
||||
return fmt.Errorf("task %s is missing dump_to path: %w", t.Name, ErrMissingField)
|
||||
}
|
||||
|
||||
if s, err := os.Stat(t.DumpToPath); err != nil {
|
||||
if stat, err := os.Stat(t.DumpToPath); err != nil {
|
||||
if !errors.Is(err, fs.ErrNotExist) {
|
||||
return fmt.Errorf("task %s: invalid dump_to: could not stat path: %v: %w", t.Name, err, ErrInvalidConfigValue)
|
||||
return fmt.Errorf(
|
||||
"task %s: invalid dump_to: could not stat path: %s: %w",
|
||||
t.Name,
|
||||
t.DumpToPath,
|
||||
ErrInvalidConfigValue,
|
||||
)
|
||||
}
|
||||
} else if s.Mode().IsDir() {
|
||||
} else if stat.Mode().IsDir() {
|
||||
return fmt.Errorf("task %s: dump_to cannot be a directory: %w", t.Name, ErrInvalidConfigValue)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user