G-code Assisted Phase Unwrapping For Autonomous Error Detection and Correction in 3D Printing