Skip to content
Snippets Groups Projects
Select Git revision
  • feat/320-cttc-ietf-simap-basic-support-with-kafka-yang-push
  • feat/310-cttc-implement-nbi-connector-to-interface-with-osm-client
  • feat/292-cttc-implement-integration-test-for-ryu-openflow
  • develop protected
  • feat/324-tid-nbi-ietf_l3vpn-deploy-fail
  • feat/321-add-support-for-gnmi-configuration-via-proto
  • feat/322-add-read-support-for-ipinfusion-devices-via-netconf
  • feat/323-add-support-for-restconf-protocol-in-devices
  • feat/policy-refactor
  • feat/192-cttc-implement-telemetry-backend-collector-gnmi-openconfig
  • feat/307-update-python-version
  • feat/telemetry-collector-int
  • feat/automation-revisited
  • feat/313-tid-new-tapi-service-for-lsp-configuration-2
  • cnit_tapi
  • feat/161-tid-creation-of-ip-link-with-supporting-coherent-pluggable-to-pluggable-connection
  • feat/312-tid-new-service-to-configure-interfaces-via-openconfig
  • openroadm-flex-grid
  • feat/314-tid-new-service-for-ipowdm-configuration-fron-orchestrator-to-ipowdm-controller
  • feat/308-code-formatting
  • v5.0.0 protected
  • v4.0.0 protected
  • demo-dpiab-eucnc2024
  • v3.0.0 protected
  • v2.1.0 protected
  • v2.0.0 protected
  • v1.0.0 protected
27 results

ServiceExceptions.py

Blame
  • Lluis Gifre's avatar
    Lluis Gifre Renom authored
    - Subscriptions to be implemented
    42259aa4
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ServiceExceptions.py 1.82 KiB
    import grpc
    from typing import Iterable, Union
    
    class ServiceException(Exception):
        def __init__(
            self, code : grpc.StatusCode, details : str, extra_details : Union[str, Iterable[str]] = []
            ) -> None:
    
            self.code = code
            if isinstance(extra_details, str): extra_details = [extra_details]
            self.details = '; '.join(map(str, [details] + extra_details))
            super().__init__(self.details)
    
    class NotFoundException(ServiceException):
        def __init__(
            self, object_name : str, object_uuid: str, extra_details : Union[str, Iterable[str]] = []
            ) -> None:
    
            details = '{:s}({:s}) not found'.format(str(object_name), str(object_uuid))
            super().__init__(grpc.StatusCode.NOT_FOUND, details, extra_details=extra_details)
    
    class AlreadyExistsException(ServiceException):
        def __init__(
            self, object_name : str, object_uuid: str, extra_details : Union[str, Iterable[str]] = None
            ) -> None:
    
            details = '{:s}({:s}) already exists'.format(str(object_name), str(object_uuid))
            super().__init__(grpc.StatusCode.ALREADY_EXISTS, details, extra_details=extra_details)
    
    class InvalidArgumentException(ServiceException):
        def __init__(
            self, argument_name : str, argument_value: str, extra_details : Union[str, Iterable[str]] = None
            ) -> None:
    
            details = '{:s}({:s}) is invalid'.format(str(argument_name), str(argument_value))
            super().__init__(grpc.StatusCode.INVALID_ARGUMENT, details, extra_details=extra_details)
    
    class OperationFailedException(ServiceException):
        def __init__(
            self, operation : str, extra_details : Union[str, Iterable[str]] = None
            ) -> None:
    
            details = 'Operation({:s}) failed'.format(str(operation))
            super().__init__(grpc.StatusCode.INTERNAL, details, extra_details=extra_details)