File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,12 @@ Core functions for any Bash program
13
13
* [ core.err_set()] ( #coreerr_set )
14
14
* [ core.err_clear()] ( #coreerr_clear )
15
15
* [ core.err_exists()] ( #coreerr_exists )
16
+ * [ core.err_print()] ( #coreerr_print )
16
17
* [ core.print_stacktrace()] ( #coreprint_stacktrace )
17
18
* [ core.print_error()] ( #coreprint_error )
18
19
* [ core.print_warn()] ( #coreprint_warn )
19
20
* [ core.print_info()] ( #coreprint_info )
21
+ * [ core.panic()] ( #corepanic )
20
22
* [ core.should_output_color()] ( #coreshould_output_color )
21
23
* [ core.get_package_info()] ( #coreget_package_info )
22
24
* [ core.init()] ( #coreinit )
@@ -126,6 +128,10 @@ _does_ exist
126
128
127
129
_ Function has no arguments._
128
130
131
+ ### core.err_print()
132
+
133
+ Prints the current error stored
134
+
129
135
### core.print_stacktrace()
130
136
131
137
Prints stacktrace
@@ -167,6 +173,10 @@ Print an informative message to standard output
167
173
168
174
* ** $1** (string): message
169
175
176
+ ### core.panic()
177
+
178
+ Use when a serious fault occurs. It will print the current ERR (if it exists)
179
+
170
180
### core.should_output_color()
171
181
172
182
Determine if color should be printed. Note that this doesn't
Original file line number Diff line number Diff line change @@ -263,6 +263,13 @@ core.err_exists() {
263
263
fi
264
264
}
265
265
266
+ # @description Prints the current error stored
267
+ core.err_print () {
268
+ printf ' %s\n' ' Error found:'
269
+ printf ' %s\n' " ERRCODE: $ERRCODE " >&2
270
+ printf ' %s\n' " ERR: $ERR " >&2
271
+ }
272
+
266
273
# @description Prints stacktrace
267
274
# @noargs
268
275
# @example
@@ -293,6 +300,7 @@ core.print_stacktrace() {
293
300
294
301
printf ' %s\n' " in ${FUNCNAME[$i]} ($file :${BASH_LINENO[$i-1]} )"
295
302
303
+ # shellcheck disable=SC1007
296
304
if ! CDPATH= cd -- " $old_cd " ; then
297
305
cd_failed=' yes'
298
306
fi
@@ -327,6 +335,14 @@ core.print_info() {
327
335
printf ' %s\n' " Info: ${FUNCNAME[1]}${msg: +" : " } $msg "
328
336
}
329
337
338
+ # @description Use when a serious fault occurs. It will print the current ERR (if it exists)
339
+ core.panic () {
340
+ if core.err_exists; then
341
+ core.err_print
342
+ fi
343
+ core.print_stacktrace
344
+ }
345
+
330
346
# @description Determine if color should be printed. Note that this doesn't
331
347
# use tput because simple environment variable checking heuristics suffice
332
348
core.should_output_color () {
You can’t perform that action at this time.
0 commit comments