Add defensive code around pretty printer.