# Path: statik/utils.py
# def uncapitalize(s):
#     """If the given string begins with a capital letter, it converts it to lowercase."""
#     return (s[:1].lower() + s[1:]) if s else ""


from statik.utils import uncapitalize
class ViewError(StatikError):
    error_kind = "View error"
    exit_code = 6

    def __init__(self, view_name=None, **kwargs):
        super(ViewError, self).__init__(**kwargs)
        self.view_name = view_name
    
    def get_error_message(self):
        return (
            "In view \"%s\", %s" % (self.view_name, uncapitalize(self.error_message))
        ) if self.view_name else self.error_message.capitalize()


class InternalError(StatikError):
    """In the (hopefully rare case) that an internal error occurs, this kind of error
    will be thrown. Will probably only happen when using Statik as a library."""
    error_kind = "Internal error"
    exit_code = 7


class ReservedFieldNameError(ModelError):
    def __init__(self, model_name, field_name, **kwargs):
        super(ReservedFieldNameError, self).__init__(model_name, **kwargs)
        self.field_name = field_name
        self.error_message = "the field name \"%s\" is reserved." % self.field_name


class InvalidFieldTypeError(ModelError):
    def __init__(self, model_name, field_name, expected_field_type=None, **kwargs):

# Path: statik/utils.py
# def uncapitalize(s):
#     """If the given string begins with a capital letter, it converts it to lowercase."""
#     return (s[:1].lower() + s[1:]) if s else ""


# Path: statik/errors.py
from statik.utils import uncapitalize

class ViewError(StatikError):
    error_kind = "View error"
    exit_code = 6

    def __init__(self, view_name=None, **kwargs):
        super(ViewError, self).__init__(**kwargs)
        self.view_name = view_name
    
    def get_error_message(self):
        return (
            "In view \"%s\", %s" % (self.view_name, uncapitalize(self.error_message))
        ) if self.view_name else self.error_message.capitalize()


class InternalError(StatikError):
    """In the (hopefully rare case) that an internal error occurs, this kind of error
    will be thrown. Will probably only happen when using Statik as a library."""
    error_kind = "Internal error"
    exit_code = 7


class ReservedFieldNameError(ModelError):
    def __init__(self, model_name, field_name, **kwargs):
        super(ReservedFieldNameError, self).__init__(model_name, **kwargs)
        self.field_name = field_name
        self.error_message = "the field name \"%s\" is reserved." % self.field_name


class InvalidFieldTypeError(ModelError):
    def __init__(self, model_name, field_name, expected_field_type=None, **kwargs):

        super(InvalidFieldTypeError, self).__init__(model_name, **kwargs)