from __future__ import annotations

from typing import Optional

from sila2.framework.errors.defined_execution_error import DefinedExecutionError

from .authorizationproviderservice_feature import AuthorizationProviderServiceFeature


class AuthorizationFailed(DefinedExecutionError):
    def __init__(self, message: Optional[str] = None):
        if message is None:
            message = "The provided access token is not valid for the given server/feature."
        super().__init__(
            AuthorizationProviderServiceFeature.defined_execution_errors["AuthorizationFailed"], 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__(
            AuthorizationProviderServiceFeature.defined_execution_errors["InvalidAccessToken"], message=message
        )
