Yes, since this code will be identical in the two sections a new function will be the best solution. SystemHealthGadgetWidget::showErrorCodes ?