fix gallery exception handling