Further simplify API error handling logic.
Make API and CLI interfaces consistent.