Add more comprehensive error checking to item_controller.js