-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrorprefixinfoquark.go
105 lines (89 loc) · 2.69 KB
/
errorprefixinfoquark.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package errpref
import (
"fmt"
"sync"
)
type errorPrefixInfoQuark struct {
lock *sync.Mutex
}
// testValidityOfErrorPrefixInfo - Performs a diagnostic review of
// the input parameter 'errPrefixInfo', an instance of
// ErrorPrefixInfo. The purpose of this diagnostic review is to
// determine whether this ErrorPrefixInfo instance is valid in all
// respects.
//
//
// ----------------------------------------------------------------
//
// Input Parameters
//
// errPrefixInfo *ErrorPrefixInfo
// - A pointer to an instance of ErrorPrefixInfo. This object
// will be evaluated to determine whether or not it is a
// valid instance.
//
//
// ePrefix string
// - This is an error prefix which is included in all returned
// error messages. Usually, it contains the names of the calling
// method or methods. Be sure to leave a space at the end of
// 'ePrefix'.
//
//
// -----------------------------------------------------------------
//
// Return Values
//
// isValid bool
// - This returned boolean value will signal whether the input
// parameter, 'errPrefixInfo', is valid, or not. If the
// 'errPrefixInfo' object contains valid data, this method
// returns 'true'. If the data is invalid, this method will
// return 'false'.
//
// err error
// - If the input parameter object, 'errPrefixInfo', contains
// invalid data, a detailed error message will be returned
// identifying the invalid data item.
//
// If the input parameter object, 'errPrefixInfo', is valid,
// this error parameter will be set to 'nil'.
//
func (ePrefDtoQuark *errorPrefixInfoQuark) testValidityOfErrorPrefixInfo(
errPrefixInfo *ErrorPrefixInfo,
ePrefix string) (
isValid bool,
err error) {
if ePrefDtoQuark.lock == nil {
ePrefDtoQuark.lock = new(sync.Mutex)
}
ePrefDtoQuark.lock.Lock()
defer ePrefDtoQuark.lock.Unlock()
ePrefix += "errorPrefixInfoQuark.testValidityOfErrorPrefixInfo() "
isValid = false
if errPrefixInfo == nil {
err = fmt.Errorf("%v\n"+
"\nInput parameter 'errPrefixInfo' is INVALID!\n"+
"'errPrefixInfo' is a nil pointer!\n",
ePrefix)
return isValid, err
}
errPrefixInfo.lenErrorPrefixStr =
uint(len(errPrefixInfo.errorPrefixStr))
if errPrefixInfo.lenErrorPrefixStr == 0 {
err =
fmt.Errorf("%v\n"+
"Error: Error Prefix is an empty string!\n",
ePrefix)
return isValid, err
}
errPrefixInfo.lenErrorContextStr =
uint(len(errPrefixInfo.errorContextStr))
if errPrefixInfo.lenErrorContextStr == 0 {
errPrefixInfo.errPrefixHasContextStr = false
} else {
errPrefixInfo.errPrefixHasContextStr = true
}
isValid = true
return isValid, err
}