Improve CLI error handling