ExternalCommand: use exceptions instead of return values.

Fixes #3549