Skip to content

incendium.util.get_function_name

César Román edited this page Aug 11, 2021 · 14 revisions

Description

Returns the name of the function last called.

Syntax

get_function_name()

Returns:

  • str: Function's name.

Recommendations

None.

Code Examples

import traceback

from incendium import util as _util
from incendium.exceptions import ApplicationError


def failed_function():
    try:
        # TODO: Do something important
    except (IOError, KeyError) as e:
        # An error occured.
        message = "An unexpected error occurred in {}. \n{}".format(
            _util.get_function_name(),
            "\n".join(traceback.format_exc().splitlines()),
        )
        raise ApplicationError(message, e)
Clone this wiki locally