/
errors.go
57 lines (46 loc) · 1.29 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
// Tideland Go Library - Scroller
//
// 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 scroller
//--------------------
// IMPORTS
//--------------------
import (
"github.com/tideland/golib/errors"
)
//--------------------
// CONSTANTS
//--------------------
// Error codes of the scroller package.
const (
ErrNoSource = iota + 1
ErrNoTarget
ErrNegativeLines
)
var errorMessages = errors.Messages{
ErrNoSource: "cannot start scroller: no source",
ErrNoTarget: "cannot start scroller: no target",
ErrNegativeLines: "negative number of lines not allowed: %d",
}
//--------------------
// TESTING
//--------------------
// IsNoSourceError returns true, if the error signals that
// no source has been passed.
func IsNoSourceError(err error) bool {
return errors.IsError(err, ErrNoSource)
}
// IsNoTargetError returns true, if the error signals that
// no target has been passed.
func IsNoTargetError(err error) bool {
return errors.IsError(err, ErrNoTarget)
}
// IsNegativeLinesError returns true, if the error shows the
// setting of a negative number of lines to start with.
func IsNegativeLinesError(err error) bool {
return errors.IsError(err, ErrNegativeLines)
}
// EOF