cancel
Showing results for 
Search instead for 
Did you mean: 

Return null in AttributeRepository instead of throwing exception

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.
0 Kudos

Return null in AttributeRepository instead of throwing exception

Wouldn't it make more sense, more consistent and be more extendable if the get operation returns null?

 

As it is now, I need to handle the exception thrown by the system or run my own check first to check if the attribute that I'm looking for isn't there. By comparison, the getList operation returns an empty if Magento can't find what I'm looking for.

 

Wouldn't it be better to return null or empty... something, so user can choose how they want to deal with this situation. Throwing exception basically just tells the user that the system think what they are doing is an error/wrong, when it's really subjective. There's lots of situation where looking for something that isn't there is not wrong, just let the user handles the situation themselves.