Skip to content

incendium.util.get_function_name

Cesar Roman edited this page Sep 23, 2020 · 14 revisions

Description

Returns the name of the function last called.

Syntax

get_function_name()

Returns:

  • str: Function's name.

Recommendations

None.

Code Examples

# Imports
import traceback

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

def failed_function():
    try:
        # TODO: Do something important
    except (IOError, KeyError), 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