Proper error handling for cmd line