Skip to content

Commit

Permalink
chore: improve error trace formatting in script
Browse files Browse the repository at this point in the history
  • Loading branch information
LangLangBart committed May 9, 2024
1 parent 34c90bb commit bc1e09b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gh-find-code
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ error_handler() {
:
else
{
echo
echo "ERROR TRACE: ${BASH_SOURCE[0]##*/}:$lineno command '$msg' exited with status $exit_code"
command "$bat_executable" --color always --number --language bash \
--terminal-width $((${COLUMNS:-$(tput cols)} - 4)) --highlight-line "$lineno" \
--line-range=$((lineno - 3)):+7 "${BASH_SOURCE[0]}" | command sed 's/^/ /;4s/ />>/'
command "$bat_executable" \
--color always \
--highlight-line "$lineno" \
--language bash \
--line-range $((lineno - 3)):+7 \
--style numbers \
--terminal-width $((${COLUMNS:-$(tput cols)} - 4)) "${BASH_SOURCE[0]}" |
command sed 's/^/ /;4s/ />>/'
} >&2
fi
exit "$exit_code"
Expand Down

0 comments on commit bc1e09b

Please sign in to comment.