How to Check and Delete Failed Feature?

I'd a 'Delete and Patch' feature in sheet-metal after the Flat-Pattern feature.

Depending upon the geometry, this 'Delete and Patch' feature fails.

I want a macro which will turn ON the 'DefaultSM-FLAT-PATTERN' configuration, checks any failed feature. If found any failed feature then it'll delete that failed feature and save the file in the Default configuration.

SolidworksApi macros