From c7560b2eaaf7797129fea63b07d970fdc09f4898 Mon Sep 17 00:00:00 2001 From: speatzle Date: Tue, 21 May 2024 16:29:30 +0200 Subject: [PATCH] Move Error to constants --- constants/error.go | 5 +++++ task/task.go | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 constants/error.go diff --git a/constants/error.go b/constants/error.go new file mode 100644 index 0000000..c375e01 --- /dev/null +++ b/constants/error.go @@ -0,0 +1,5 @@ +package constants + +import "fmt" + +var ErrTaskDoesNotExist = fmt.Errorf("Task does not Exist") diff --git a/task/task.go b/task/task.go index 5dd00bc..c2d3ef3 100644 --- a/task/task.go +++ b/task/task.go @@ -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 {