fix error handling in the inventory utility