Move Error to constants

This commit is contained in:
speatzle 2024-05-21 16:29:30 +02:00
parent 4c1e29265e
commit c7560b2eaa
2 changed files with 7 additions and 2 deletions

5
constants/error.go Normal file
View file

@ -0,0 +1,5 @@
package constants
import "fmt"
var ErrTaskDoesNotExist = fmt.Errorf("Task does not Exist")

View file

@ -61,7 +61,7 @@ func Get(r types.TaskStatusRequest) (*types.Task, error) {
t, ok := tasks[r.ID]
if !ok {
return nil, fmt.Errorf("Task does not Exist")
return nil, constants.ErrTaskDoesNotExist
}
res := *t
@ -82,7 +82,7 @@ func DeleteTask(id int) error {
_, ok := tasks[id]
if !ok {
return fmt.Errorf("Task does not Exist")
return constants.ErrTaskDoesNotExist
}
if tasks[id].Status == constants.TASK_STATUS_RUNNING {