# -*- coding: utf-8 -*-
"""
This module contains functions for raising errors or warnings, depending on if the tools are being run in batch mode
or in testing mode, or neither (normal mode.
There are also classes for displaying widgets showing the error or warning message.
Functions
---------
- :func:`inform_user <artv2_utilities.error_utilities.inform_user>`
- :func:`raise_error <artv2_utilities.error_utilities.raise_error>`
"""
import maya.cmds as cmds
import interface_utilities as interface_utils
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
[docs]def raise_error(message):
"""
Shows a widget (QMessageBox) with the error message if the tools are not being run in batch or test mode. Otherwise,
it will just raise a normal RuntimeError with the message.
:param message: Detailed message describing the error.
"""
if not cmds.about(batch=True):
if cmds.optionVar(exists="ARTv2_RUNNING_TESTS") == 0:
inst = interface_utils.ErrorWidget(message)
inst.exec_()
else:
raise RuntimeError(message)
else:
raise RuntimeError(message)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #