convert errors to exceptions like in magento