Suppress error bars on empty bins in TH1 plot?

Is there a way to plot a TH1 with the usual error bars, but only for non-empty bins?

The error bars are never drawn if the bin error is null. In your case it looks like your bin content is null, but you have set the bin error.