I have the following

    (defun isearch-del-fail-or-char ()
      "Delete failed isearch text, or if there is none, a single character."
      (interactive)
      (if (isearch-fail-pos)
          (delete-region (isearch-fail-pos) (point))
        (isearch-del-char)))
    
    (define-key isearch-mode-map (kbd "DEL") 'isearch-del-fail-or-char)

The purpose of the code is to make `delete` in isearch delete the entire failed string (or if there is no failed string just a single character). 

However, `delete-region` is deleting text from the buffer `isearch` is searching in, not the isearch buffer itself. 

What is the proper way to do this? Critique on the rest of my emacs lisp style is also welcome :)