exit with an error code in cli mode and re-format error message