-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy patherrors.go
More file actions
35 lines (29 loc) · 832 Bytes
/
errors.go
File metadata and controls
35 lines (29 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package celeriac
import (
"errors"
"fmt"
// Package dependencies
log "github.com/sirupsen/logrus"
)
// Global Errors
var (
// ErrInvalidTaskID is raised when an invalid task ID has been detected
ErrInvalidTaskID = errors.New("invalid task ID specified")
// ErrInvalidTaskName is raised when an invalid task name has been detected
ErrInvalidTaskName = errors.New("invalid task name specified")
)
// Fail logs the error and exits the program
// Only use this to handle critical errors
func Fail(err error, msg string) {
if err != nil {
log.Fatalf("%s: %s", msg, err)
panic(fmt.Sprintf("%s: %s", msg, err))
}
}
// Log only logs the error but doesn't exit the program
// Use this to log errors that should not exit the program
func Log(err error, msg string) {
if err != nil {
log.Fatalf("%s: %s", msg, err)
}
}