Throw exception instead of logging in debug mode.

Refs #4021