iptoux / bash_error_lib

An standalone bash "library" that catches mostly all errors of an bash script.
Creative Commons Zero v1.0 Universal
3 stars 0 forks source link

BUG & External Errors #7

Closed iptoux closed 1 year ago

iptoux commented 1 year ago

Hey,

i recently noticed an major bug that prevents to catch external errors. I had to do some heavy changes to the code. An update to repo will be come soon. And yes you are right, an stack-trace also come to library!

iptoux@2040:~/gits/bash_error_lib$ ./test.sh 
Singleline default external error by internal call, no line, source, func.
MSG:  No such file or directory
CAUSE BY: cat
CALL:  lol
SRC: ./test.sh
LINE: 248
STACK:
  huhu @ ./test.sh:248
  main @ ./test.sh:251
Jumping to cleanUp!
iptoux commented 1 year ago

UPDATE

Mostly all is done now, only the output of the source code is missing. I had recoded a big part, but now it is all cleaner now, i split a big function an changed some behavior and handling.

Commits: https://github.com/iptoux/bash_error_lib/compare/main...7-bug-external-errors

error_out_msg() {

    local prfx cli_out

    prfx=">> "

    cli_out="\n------------------------------------------------\n"

    cli_out+="${prfx}ERROR (${ECONT["code"]}) - ${ECONT["type"]}\n\n"
    cli_out+="${prfx}MSG:${ECONT["msg"]}"
    cli_out+="${prfx}CALL/CMD/ARG:${ECONT["call"]}\n\n"
    cli_out+="${prfx}CAUSE BY: ${ECONT["cause"]} IN: ${ECONT["source"]} ON LINE: ${ECONT["line"]}\n"
    cli_out+="${prfx}FULLSTACK:"

    echo -e "${cli_out}"

}
iptoux@2040:~/gits/bash_error_lib$ ./test.sh 

------------------------------------------------
>> ERROR (127) - Inline command/func not found.

>> MSG: command not found
>> CALL/CMD/ARG: huhu

>> CAUSE BY: Script IN: ./test.sh ON LINE: 256
>> FULLSTACK:
  main @ ./test.sh:256

Jumping to cleanUp!
iptoux@2040:~/gits/bash_error_lib$