# Copyright (c) 2020 CloudZero - ALL RIGHTS RESERVED - PROPRIETARY AND CONFIDENTIAL
# Unauthorized copying of this file and/or project, via any medium is strictly prohibited.
# Direct all questions to legal@cloudzero.com


class BadConfigurationFile(Exception):
    """
    Thrown if we are unable to load_settings the configuration file
    """

    pass


class DidNotCache(Exception):
    """Thrown when we can't, won't or don't want to cache something"""

    pass


class APIError(Exception):
    """
    Thrown if there is a CloudZero API Error
    """

    def __init__(self, message, code=None, status_code=None, server_response=None, **kwargs):
        super().__init__(message, kwargs)
        self.code = code and int(code)
        self.status_code = status_code
        self.server_response = server_response
        self._message = message

    def __str__(self):
        return self._message


class MalformedS3Url(Exception):
    """Thrown when we have a malformed S3 URL"""

    pass


class CzOpsApiException(Exception):
    """
    Thrown when there is a CZ Ops API-specific error.

    This is similar to APIError but specific to the CZ Ops API client.
    """

    def __init__(self, message, code=None, status_code=None, server_response=None, **kwargs):
        super().__init__(message, kwargs)
        self.code = code and int(code)
        self.status_code = status_code
        self.server_response = server_response
        self._message = message

    def __str__(self):
        return self._message
