Skip to content

Instantly share code, notes, and snippets.

@nk23x
Last active January 26, 2022 12:17
Show Gist options
  • Select an option

  • Save nk23x/f6bba6464d0090484ef4c3c469ab2af1 to your computer and use it in GitHub Desktop.

Select an option

Save nk23x/f6bba6464d0090484ef4c3c469ab2af1 to your computer and use it in GitHub Desktop.
make java exception messages readable
#!/bin/bash
##
## patterns copied from
## https://raw.githubusercontent.com/staxmanade/ExceptionMessageBeautifier/master/src/ExceptionMessageBeautifier.js
## see also:
## https://superuser.com/a/747905
##
PERL_CMD="perl -pe 's/ at/\\r\\n at/g; s/ ---> /\\r\\n ---> /g; s/\) at /\\r\\n at /g; s/ --- End of inner exception stack trace ---/\\r\\n --- End of inner exception stack trace ---/g;'"
FILE_IN="$1"
if [ -p /dev/stdin ]; then
while IFS= read INPUT; do
cat ${INPUT} | ${PERL_CMD}
done
else
if [ -f $FILE_IN ]; then
cat ${FILE_IN} | ${PERL_CMD}
else
echo -e "\n no input submitted.\n syntax:\n $0 {FILE}\n cat {FILE} | $0\n\n"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment