Fixed error handling in app controller