-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrprefixdelimitersmechanics.go
253 lines (205 loc) · 6.8 KB
/
errprefixdelimitersmechanics.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
package errpref
import (
"fmt"
"sync"
)
type errPrefixDelimitersMechanics struct {
lock *sync.Mutex
}
// ptr - Returns a pointer to a new instance of errPrefixDelimitersMechanics.
//
func (ePrefDelimitersMech errPrefixDelimitersMechanics) ptr() *errPrefixDelimitersMechanics {
if ePrefDelimitersMech.lock == nil {
ePrefDelimitersMech.lock = new(sync.Mutex)
}
ePrefDelimitersMech.lock.Lock()
defer ePrefDelimitersMech.lock.Unlock()
return &errPrefixDelimitersMechanics{
lock: new(sync.Mutex),
}
}
// setErrPrefDelimiters - Receives a pointer to an instance of
// ErrPrefixDelimiters and proceeds to overwrite and reset the data
// values for all internal member variables in that instance.
//
// The new values are generated from string values submitted as
// input parameters.
//
//
// ----------------------------------------------------------------
//
// Input Parameters
//
// ePrefDelimiters *ErrPrefixDelimiters
// - A pointer to an instance of ErrPrefixDelimiters. All of
// the data value encapsulated by this instance will be
// deleted, overwritten and replaced with new data values
// generated from the following input parameters.
//
//
// newLinePrefixDelimiters string
// - The contents of this string will be used to parse error
// prefix strings on separate lines of text.
//
// If an empty string (string length zero) is passed for this
// parameter, an error will be returned.
//
//
// inLinePrefixDelimiters string
// - The contents of this string will be used to separate
// multiple error prefix elements within a single line of
// text.
//
// If an empty string (string length zero) is passed for this
// parameter, an error will be returned.
//
//
// newLineContextDelimiters string
// - The contents of this string will be used to parse error
// context elements on separate lines of text.
//
// If an empty string (string length zero) is passed for this
// parameter, an error will be returned.
//
//
// inLineContextDelimiters string
// - The contents of this string will be used to separate
// multiple error context elements within a single line of
// text.
//
// If an empty string (string length zero) is passed for this
// parameter, an error will be returned.
//
//
// ePrefix string
// - A string containing the name of the function which called
// this method. If an error occurs this string will be
// prefixed to the beginning of the returned error message.
//
// This parameter is optional. If an error prefix is not
// required, submit an empty string for this parameter ("").
//
//
// -----------------------------------------------------------------
//
// Return Values
//
// error
// - If this method completes successfully, the returned error
// Type is set equal to 'nil'.
//
// If errors are encountered during processing, the returned
// error Type will encapsulate an error message.
//
// In the event of an error, the value of parameter
// 'ePrefix' will be prefixed and attached to the beginning
// of the error message.
//
func (ePrefDelimitersMech *errPrefixDelimitersMechanics) setErrPrefDelimiters(
ePrefDelimiters *ErrPrefixDelimiters,
newLinePrefixDelimiters string,
inLinePrefixDelimiters string,
newLineContextDelimiters string,
inLineContextDelimiters string,
ePrefix string) (
err error) {
if ePrefDelimitersMech.lock == nil {
ePrefDelimitersMech.lock = new(sync.Mutex)
}
ePrefDelimitersMech.lock.Lock()
defer ePrefDelimitersMech.lock.Unlock()
ePrefix += "\nerrPrefixDelimitersMechanics.setErrPrefDelimiters() "
if ePrefDelimiters == nil {
err = fmt.Errorf("%v\n"+
"Input parameter 'ePrefDelimiters' is INVALID!\n"+
"'ePrefDelimiters' is a nil pointer!\n",
ePrefix)
return err
}
if len(newLinePrefixDelimiters) == 0 {
err = fmt.Errorf("%v\n"+
"Input parameter 'newLinePrefixDelimiter' is INVALID!\n"+
"'newLinePrefixDelimiter' is an empty string!\n",
ePrefix)
return err
}
if len(inLinePrefixDelimiters) == 0 {
err = fmt.Errorf("%v\n"+
"Input parameter 'inLinePrefixDelimiters' is INVALID!\n"+
"'inLinePrefixDelimiters' is an empty string!\n",
ePrefix)
return err
}
if len(newLineContextDelimiters) == 0 {
err = fmt.Errorf("%v\n"+
"Input parameter 'newLineContextDelimiter' is INVALID!\n"+
"'newLineContextDelimiter' is an empty string!\n",
ePrefix)
return err
}
if len(inLineContextDelimiters) == 0 {
err = fmt.Errorf("%v\n"+
"Input parameter 'inLineContextDelimiter' is INVALID!\n"+
"'inLineContextDelimiter' is an empty string!\n",
ePrefix)
return err
}
ePrefDelimiters.inLinePrefixDelimiter =
inLinePrefixDelimiters
ePrefDelimiters.lenInLinePrefixDelimiter =
uint(len(ePrefDelimiters.inLinePrefixDelimiter))
ePrefDelimiters.newLinePrefixDelimiter =
newLinePrefixDelimiters
ePrefDelimiters.lenNewLinePrefixDelimiter =
uint(len(ePrefDelimiters.newLinePrefixDelimiter))
ePrefDelimiters.inLineContextDelimiter =
inLineContextDelimiters
ePrefDelimiters.lenInLineContextDelimiter =
uint(len(ePrefDelimiters.inLineContextDelimiter))
ePrefDelimiters.newLineContextDelimiter =
newLineContextDelimiters
ePrefDelimiters.lenNewLineContextDelimiter =
uint(len(ePrefDelimiters.newLineContextDelimiter))
return err
}
// setToDefault - Receives a pointer to an instance of
// ErrPrefixDelimiters and proceeds to set the data values for this
// instance to those of the system default.
//
func (ePrefDelimitersMech *errPrefixDelimitersMechanics) setToDefault(
ePrefDelimiters *ErrPrefixDelimiters,
ePrefix string) (
err error) {
if ePrefDelimitersMech.lock == nil {
ePrefDelimitersMech.lock = new(sync.Mutex)
}
ePrefDelimitersMech.lock.Lock()
defer ePrefDelimitersMech.lock.Unlock()
ePrefix += "\nerrPrefixDelimitersMechanics.setToDefault() "
if ePrefDelimiters == nil {
err = fmt.Errorf("%v\n"+
"Input parameter 'ePrefDelimiters' is INVALID!\n"+
"'ePrefDelimiters' is a nil pointer!\n",
ePrefix)
return err
}
delimiters :=
errPrefElectron{}.ptr().getDelimiters()
ePrefDelimiters.inLinePrefixDelimiter =
delimiters.inLinePrefixDelimiter
ePrefDelimiters.lenInLinePrefixDelimiter =
uint(len(ePrefDelimiters.inLinePrefixDelimiter))
ePrefDelimiters.newLinePrefixDelimiter =
delimiters.newLinePrefixDelimiter
ePrefDelimiters.lenNewLinePrefixDelimiter =
uint(len(ePrefDelimiters.newLinePrefixDelimiter))
ePrefDelimiters.inLineContextDelimiter =
delimiters.inLineContextDelimiter
ePrefDelimiters.lenInLineContextDelimiter =
uint(len(ePrefDelimiters.inLineContextDelimiter))
ePrefDelimiters.newLineContextDelimiter =
delimiters.newLineContextDelimiter
ePrefDelimiters.lenNewLineContextDelimiter =
uint(len(ePrefDelimiters.newLineContextDelimiter))
return err
}