Fix exception handling in CreateGallery