Skip to content
Sarj Code Standards

no-value-error-forwarder

Raise ValueError at the failure boundary instead of forwarding through a helper.

Why

A helper that only forwards a message into ValueError hides the failure behind another call and stack frame without expressing a domain operation.

Fix

Review whether callers can raise ValueError directly. Preserve error messages, chaining and externally used callable contracts; shared error formatting can still deserve a helper.

Examples

Before — flagged A helper only forwards its message
app/parse.py
def fail(message):
raise ValueError(message)
fail("invalid input")
After — preferred The failure stays at its owning boundary
app/parse.py
def parse(value):
if not value:
raise ValueError("invalid input")
return value