Move Error to constants
This commit is contained in:
parent
4c1e29265e
commit
c7560b2eaa
2 changed files with 7 additions and 2 deletions
5
constants/error.go
Normal file
5
constants/error.go
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
package constants
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
var ErrTaskDoesNotExist = fmt.Errorf("Task does not Exist")
|
|
@ -61,7 +61,7 @@ func Get(r types.TaskStatusRequest) (*types.Task, error) {
|
||||||
|
|
||||||
t, ok := tasks[r.ID]
|
t, ok := tasks[r.ID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("Task does not Exist")
|
return nil, constants.ErrTaskDoesNotExist
|
||||||
}
|
}
|
||||||
|
|
||||||
res := *t
|
res := *t
|
||||||
|
@ -82,7 +82,7 @@ func DeleteTask(id int) error {
|
||||||
|
|
||||||
_, ok := tasks[id]
|
_, ok := tasks[id]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Task does not Exist")
|
return constants.ErrTaskDoesNotExist
|
||||||
}
|
}
|
||||||
|
|
||||||
if tasks[id].Status == constants.TASK_STATUS_RUNNING {
|
if tasks[id].Status == constants.TASK_STATUS_RUNNING {
|
||||||
|
|
Loading…
Add table
Reference in a new issue