Added error handling to the cube printer

As the title said.