-
-
Notifications
You must be signed in to change notification settings - Fork 2
incendium.exceptions.ApplicationError
César Román edited this page Apr 30, 2024
·
10 revisions
-
exceptions.BaseException
-
exceptions.Exception
-
incendium.exceptions.JavaError
- incendium.exceptions.ApplicationError
-
incendium.exceptions.JavaError
-
exceptions.Exception
Args:
- message (
str
): The error message. - inner_exception (
Throwable
): The inner Exception. Optional. Defaults toNone
. - cause (
str
): The cause of the Exception. Optional. Defaults toNone
. - remove_substring (
str
): The substring to be removed from message. Optional. Defaults toNone
.
See incendium.exceptions
recommendations.
Call from the UI; from a button's actionPerformed code.
from incendium import gui
from incendium.exceptions import ApplicationError
try:
# Call some function.
app.some_important_function()
except ApplicationError as exc:
gui.error(exc.message, "Error")
And the some_important_function
would look like this:
import traceback
from incendium import constants, util
from incendium.exceptions import ApplicationError
from java.lang import Exception as JavaException
def some_important_function():
"""Very important function."""
try:
# TODO: Do something very important.
pass
except JavaException as exc:
message = constants.UNEXPECTED_ERROR_CAUSED_BY.format(
util.get_function_name(),
"\n".join(traceback.format_exc().splitlines()),
exc.cause,
)
raise ApplicationError(message, exc, exc.cause)
except (IndexError, KeyError) as exc:
message = constants.UNEXPECTED_ERROR.format(
util.get_function_name(),
"\n".join(traceback.format_exc().splitlines()),
)
raise ApplicationError(message, exc)