better error handling in views, more generalized