-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy patherrors.go
81 lines (67 loc) · 2.01 KB
/
errors.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Tideland Go Library - Scene
//
// Copyright (C) 2014-2017 Frank Mueller / Tideland / Oldenburg / Germany
//
// All rights reserved. Use of this source code is governed
// by the new BSD license.
package scene
//--------------------
// IMPORTS
//--------------------
import (
"github.com/tideland/golib/errors"
)
//--------------------
// CONSTANTS
//--------------------
// Error codes of the scene package.
const (
ErrSceneEnded = iota + 1
ErrTimeout
ErrPropAlreadyExist
ErrPropNotFound
ErrCleanupFailed
ErrWaitedTooLong
)
var errorMessages = errors.Messages{
ErrSceneEnded: "scene already ended",
ErrTimeout: "scene %s timeout reached at %v",
ErrPropAlreadyExist: "property %q already exist",
ErrPropNotFound: "property %q does not exist",
ErrCleanupFailed: "cleanup of property %q failed",
ErrWaitedTooLong: "waiting for signal %q timed out",
}
//--------------------
// TESTING
//--------------------
// IsSceneEndedError returns true, if the error signals that
// the scene isn't active anymore.
func IsSceneEndedError(err error) bool {
return errors.IsError(err, ErrSceneEnded)
}
// IsTimeoutError returns true, if the error signals that
// the scene end after an absolute timeout.
func IsTimeoutError(err error) bool {
return errors.IsError(err, ErrTimeout)
}
// IsPropAlreadyExistError returns true, if the error signals a
// double prop key.
func IsPropAlreadyExistError(err error) bool {
return errors.IsError(err, ErrPropAlreadyExist)
}
// IsPropNotFoundError returns true, if the error signals a
// non-existing prop.
func IsPropNotFoundError(err error) bool {
return errors.IsError(err, ErrPropNotFound)
}
// IsCleanupFailedError returns true, if the error signals the
// failing of a prop error.
func IsCleanupFailedError(err error) bool {
return errors.IsError(err, ErrCleanupFailed)
}
// IsWaitedTooLongError returns true, if the error signals a
// timeout when waiting for a signal.
func IsWaitedTooLongError(err error) bool {
return errors.IsError(err, ErrWaitedTooLong)
}
// EOF