File: errors.go

package info (click to toggle)
golang-github-tideland-golib 4.24.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,144 kB
  • sloc: makefile: 4
file content (73 lines) | stat: -rw-r--r-- 2,319 bytes parent folder | download | duplicates (2)
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
// Tideland Go Library - Monitoring
//
// Copyright (C) 2009-2017 Frank Mueller / Tideland / Oldenburg / Germany
//
// All rights reserved. Use of this source code is governed
// by the new BSD license.

package monitoring

//--------------------
// IMPORTS
//--------------------

import (
	"github.com/tideland/golib/errors"
)

//--------------------
// CONSTANTS
//--------------------

// Error codes of the monitoring package.
const (
	ErrMonitoringPanicked = iota + 1
	ErrMonitoringCannotBeRecovered
	ErrMeasuringPointNotExists
	ErrStaySetVariableNotExists
	ErrDynamicStatusNotExists
)

var errorMessages = errors.Messages{
	ErrMonitoringPanicked:          "monitoring backend panicked",
	ErrMonitoringCannotBeRecovered: "monitoring backend cannot be recovered: %v",
	ErrMeasuringPointNotExists:     "measuring point %q does not exist",
	ErrStaySetVariableNotExists:    "stay-set variable %q does not exist",
	ErrDynamicStatusNotExists:      "dynamic status %q does not exist",
}

//--------------------
// TESTING
//--------------------

// IsMonitoringPanickedError returns true, if the error signals that
// the monitoring backend panicked.
func IsMonitoringPanickedError(err error) bool {
	return errors.IsError(err, ErrMonitoringPanicked)
}

// IsMonitoringCannotBeRecoveredError returns true, if the error signals that
// the monitoring backend has panicked to often and cannot be recovered.
func IsMonitoringCannotBeRecoveredError(err error) bool {
	return errors.IsError(err, ErrMonitoringCannotBeRecovered)
}

// IsMeasuringPointNotExistsError returns true, if the error signals that
// a wanted measuring point cannot be retrieved because it doesn't exists.
func IsMeasuringPointNotExistsError(err error) bool {
	return errors.IsError(err, ErrMeasuringPointNotExists)
}

// IsStaySetVariableNotExistsError returns true, if the error signals that
// a wanted stay-set variable cannot be retrieved because it doesn't exists.
func IsStaySetVariableNotExistsError(err error) bool {
	return errors.IsError(err, ErrStaySetVariableNotExists)
}

// IsDynamicStatusNotExistsError returns true, if the error signals that
// a wanted dynamic status cannot be retrieved because it doesn't exists.
func IsDynamicStatusNotExistsError(err error) bool {
	return errors.IsError(err, ErrDynamicStatusNotExists)
}

// EOF