This seems like it would do what you want and doesn't require you to write/modify/call the functions in any specific way for it to work:
$ cat tst.sh
#!/usr/bin/env bash
set -o functrace
trap 'previous_function="$FUNCNAME"' RETURN
function_x() {
false
}
if ! function_x ; then
echo "$previous_function has failed"
else
echo "call another function here"
fi
$ ./tst.sh
function_x has failed
Note that it's printing the name of the last function that ended, not the last function that started, which I assume is what you want:
$ cat tst.sh
#!/usr/bin/env bash
set -o functrace
trap 'previous_function="$FUNCNAME"' RETURN
function_y() {
false
}
function_x() {
function_y
}
if ! function_x ; then
echo "$previous_function has failed"
else
echo "call another function here"
fi
$ ./tst.sh
function_x has failed
See https://www.gnu.org/software/bash/manual/bash.html for more information on set -o functrace (or set -T) and RETURN.
To similarly get the exit status of the previous function ran, see How can I set a trap to print the name and exit status of each function as it's executed.