Add error checking to frame dumping code