Handle API errors, allow passing an array as an argument