civicrm_custom_field_delete($parms) in civicrm/api/v2/CustomGroup.php generates non-recoverable error in certain circumstances.
the problem appears to be something to do with indexing. i've only positively one set of circumstances which cause this error so far, but i'll add further comments if i identify more (i suspect there will be).
if you use civicrm_custom_field_create(...) to add a custom field with these attributes:
...then civicrm_custom_field_delete(...) successfully deletes the custom field.
however if you use these attributes:
is_searchable=1 [ Notice that is searchable is now set to 1 ]#
...then the civicrm_custom_field_delete(...) call generates a non-recoverable error with the following error message
"Sorry. A non-recoverable error has occurred.
Database Error Code: Can't DROP 'INDEX_test2_field_label'; check that column/key exists, 1091"
i've attached some code which demonstrates this (and generates the above error)