# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/client/DomoError.ipynb.

# %% auto 0
__all__ = ['DomoError', 'AuthNotProvidedError', 'DatasetNotProvidedError']

# %% ../../nbs/client/DomoError.ipynb 2
from typing import Optional

# %% ../../nbs/client/DomoError.ipynb 3
class DomoError(Exception):
    """base exception"""

    def __init__(
        self,
        entity_id: Optional[str] = None,
        function_name: Optional[str] = None,
        status: Optional[int] = None,  # API request status
        message: str = "error",  # <domo_instance>.domo.com
        domo_instance: Optional[str] = None,
    ):
        
        entity_str = f"{entity_id} :" if entity_id else ""
        function_str = f"{function_name}: " if function_name else ""
        instance_str = f" at {domo_instance}" if domo_instance else ""
        status_str = f"Status {status} - " if status else ""

        self.message = f"{function_str}{entity_str}{status_str}{message}{instance_str}"
        super().__init__(self.message)


# %% ../../nbs/client/DomoError.ipynb 6
class AuthNotProvidedError(DomoError):
    def __init__(self,
                 entity_id,
                 function_name,
                 message="valid Auth object not provided",
                 status = None,
                 domo_instance=None
                 ):

        super().__init__(entity_id=entity_id, function_name=function_name,
                         status=status, 
                         message=message, 
                         domo_instance=domo_instance)


# %% ../../nbs/client/DomoError.ipynb 7
class DatasetNotProvidedError(DomoError):
    def __init__(self,
                 function_name,
                 message="dataset_id not provided", 
                 domo_instance=None,
                 entity_id = None,
                 status=None,
                 ):

        super().__init__(entity_id=entity_id, function_name=function_name,
                         status=status,
                         message=message,
                         domo_instance=domo_instance)

