Learning Failure Prevention Skills for Safe Robot Manipulation