cancel
Showing results for 
Search instead for 
Did you mean: 

Should `toOptionArray()` return empty or throw an exception?

Should `toOptionArray()` return empty or throw an exception?

I'm populating my `toOptionArray()` via an API call. When my API fails to authenticate or otherwise fails to respond should I throw an exception or return an empty array?

 

The method expects the API data to be available, so that seems to indicate that I should throw an exception. However, Magento is not prepared to handle Exceptions thrown via toOptionArray(), so I am a bit torn over which path to take.