error handling in gallery