Error handling for invalid or null battery capacity