Source code for uibcdf_systems._private_tools.exceptions


[docs]class NotImplementedMethodError(NotImplementedError): """Exception raised when a method has not been fully implemented yet. This exception is raised when a method has been already defined but its code was not fully implemented yet. Maybe the method was just included in a developing version to be coded in the future. Or maybe the method works already for certain values of the input arguments, but not for others yet. Note ---- This exception does not require input arguments. Raises ------ NotImplementedMethodError A message is printed out with the name of the method raising the exception, the link to the API documentation, and the link to the issues board of OpenMolecularSystems' GitHub repository. Examples -------- >>> from openmolecularsystems._private_tools.exceptions import NotImplementedMethodError >>> def method_name(a, b=True): ... raise NotImplementedMethodError ... pass .. admonition:: See Also :class: attention :ref:`Developer Guide \> Exceptions \> NotImplementedMethodError <developer:exceptions:NotImplementedMethodError>` """ def __init__(self): from openmolecularsystems import __github_issues_web__ from inspect import stack all_stack_frames = stack() caller_stack_frame = all_stack_frames[1] caller_name = caller_stack_frame[3] api_doc = '' message = ( f"The \"{caller_name}\" method has not been implemented yet in the way you are using it. " f"Check {api_doc} for more information. " f"If you still want to suggest its implementation, open a new issue in {__github_issues_web__}" ) super().__init__(message)
[docs]class NotImplementedClassError(NotImplementedError): """Exception raised when a class has not been fully implemented yet. This exception is raised when a class has being already defined but its code was not fully implemented yet. Maybe the class was just included in a developing version to be coded in the future. Or maybe the class can be instantated already for certain values of the input arguments, but not for others yet. Note ---- This exception does not require input arguments. Raises ------ NotImplementedClassError A message is printed out with the name of the class raising the exception, the link to the API documentation, and the link to the issues board of OpenMolecularSystems' GitHub repository. Examples -------- >>> from openmolecularsystems._private_tools.exceptions import NotImplementedClassError >>> class ClassName(): ... def __init__(self): ... raise NotImplementedClassError ... pass .. admonition:: See Also :class: attention :ref:`Developer Guide \> Exceptions \> NotImplementedClassError <developer:exceptions:NotImplementedClassError>` """ def __init__(self): from openmolecularsystems import __github_issues_web__ from inspect import stack all_stack_frames = stack() caller_stack_frame = all_stack_frames[1] caller_name = caller_stack_frame[3] api_doc = '' message = ( f"The \"{caller_name}\" class has not been implemented yet in the way you are using it. " f"Check {api_doc} for more information. " f"If you still want to suggest its implementation, open a new issue in {__github_issues_web__}." ) super().__init__(message)
[docs]class BadCallError(ValueError): """Exception raised when a method, or a class, was not properly called or instantiated. This exception is raised when a method or a class was not properly called or instantiated. Parameters ---------- argument : str, optional The name of the possible wrong input argument. Raises ------ BadCallError A message is printed out with the name of the class or the method raising the exception, the possible wrong argument, the link to the API documentation, and the link to the issues board of OpenMolecularSystems' GitHub repository. Examples -------- >>> from openmolecularsystems._private_tools.exceptions import BadCallError >>> def method_name(item, a=True): ... if type(a) not in [int, float]: ... raise BadCallError('a') ... pass .. admonition:: See Also :class: attention :ref:`Developer Guide \> Exceptions \> BadCallError <developer:exceptions:BadCallError>` """ def __init__(self, argument=None): from openmolecularsystems import __github_issues_web__ from inspect import stack all_stack_frames = stack() caller_stack_frame = all_stack_frames[1] caller_name = caller_stack_frame[3] api_doc = '' message = f"The \"{caller_name}\" method or class was not properly invoked" if argument is not None: message += f", probably due to the \"{argument}\" input argument" message += ( f". Check {api_doc} for more information. " f"If you still need help, open a new issue in {__github_issues_web__}." ) super().__init__(message)