It's a platform limitation. Notebook tasks run through IPython, which always prints a traceback for an unhandled exception, so you can't fully suppress the extra output. sys.exit doesn't help either. In a notebook it raises SystemExit, which gets rendered as an error too, and it's less clear to read.
Recommendation: raise an exception, not sys.exit.
python
class DataQualityError(Exception):
pass
if bad_condition:
raise DataQualityError("Row count check failed: expected > 0, got 0")
The task is marked failed, and your message appears on the last line of the output, which is where people look first.
A specific exception name (not a generic RuntimeError) makes the cause obvious at a glance.
Keep the message to a single line, with the check name and the values.
To get truly minimal output, use a Python script task (or wheel) instead of a notebook. There, sys.exit("Row count check failed: expected > 0, got 0") prints only that message to stderr and fails the task with exit code 1, with no traceback.
Other things that help:
Don't use dbutils.notebook.exit() to signal failure. It ends the task as successful.
To surface the reason without opening the run, set a task value (dbutils.jobs.taskValues.set(...)) and reference it in a downstream notification or condition task.
If you paste your two examples, I'll tighten them.
Aayush Sharma