from dataclasses import dataclass


@dataclass
class CodedError(Exception):
    code: int
    message: str


class RegisterError(object):
    EMPTY_SERVICE_NAME = CodedError(
        code=-1,
        message="Service name cannot be empty",
    )

    EMPTY_ADDRESS = CodedError(
        code=-2,
        message="Service address cannot be empty",
    )

    INVALID_SERVICE_NAME = CodedError(
        code=-3,
        message="Service name must be an utf-8 string",
    )

    ADDRESS_CANNOT_BE_ENCODED_USING_UTF8 = CodedError(
        code=-4,
        message="Address must be an utf-8 string",
    )


class LocateError(object):
    INVALID_SERVICE_NAME = CodedError(
        code=-1,
        message="Service name must be an utf-8 string",
    )

    SERVICE_NOT_FOUND = CodedError(
        code=-2,
        message="Requested service was not found",
    )


class KeepAliveError(object):
    INVALID_REGISTRATION_ID = CodedError(
        code=-1,
        message="Registration id must be an utf-8 string"
    )

    SUBSCRIPTION_ID_NOT_FOUND = CodedError(
        code=-2,
        message="Subscription id was not found",
    )
