better error handling; adapt to a minor change in dimagi-utils