from __future__ import annotations

from typing import Optional

from sila2.framework.errors.defined_execution_error import DefinedExecutionError

from .authenticationservice_feature import AuthenticationServiceFeature


class AuthenticationFailed(DefinedExecutionError):
    def __init__(self, message: Optional[str] = None):
        if message is None:
            message = "The provided credentials are not valid."
        super().__init__(AuthenticationServiceFeature.defined_execution_errors["AuthenticationFailed"], message=message)


class InvalidAccessToken(DefinedExecutionError):
    def __init__(self, message: Optional[str] = None):
        if message is None:
            message = "The sent access token is not valid."
        super().__init__(AuthenticationServiceFeature.defined_execution_errors["InvalidAccessToken"], message=message)
