• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

AndreuCodina / wirio / 21498270511

29 Jan 2026 11:19PM UTC coverage: 96.293%. First build
21498270511

Pull #34

github

web-flow
Merge 507d12b98 into 07eac4736
Pull Request #34: Add ServiceContainer

194 of 196 branches covered (98.98%)

Branch coverage included in aggregate %.

321 of 338 new or added lines in 31 files covered. (94.97%)

1806 of 1881 relevant lines covered (96.01%)

0.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.33
/src/wirio/exceptions.py
1
from typing import final
1✔
2

3
from wirio._service_lookup._typed_type import TypedType
1✔
4

5

6
class WirioError(Exception):
1✔
7
    """Base exception for Wirio Dependency Injection."""
8

9

10
@final
1✔
11
class ObjectDisposedError(WirioError):
1✔
12
    """The exception that is thrown when an operation is performed on a disposed object."""
13

14
    def __init__(self) -> None:
1✔
NEW
15
        super().__init__("BaseServiceContainer")
×
16

17

18
@final
1✔
19
class NonKeyedDescriptorMisuseError(WirioError):
1✔
20
    """The exception that is thrown when a service descriptor is not keyed."""
21

22
    def __init__(self) -> None:
1✔
23
        message = "This service descriptor is not keyed"
×
24
        super().__init__(message)
×
25

26

27
@final
1✔
28
class InvalidServiceDescriptorError(WirioError):
1✔
29
    """The exception that is thrown when a service descriptor is invalid."""
30

31
    def __init__(self) -> None:
1✔
32
        super().__init__("Invalid service descriptor")
×
33

34

35
@final
1✔
36
class InvalidServiceKeyTypeError(WirioError):
1✔
37
    """The exception that is thrown when the type of the key used for lookup doesn't match the type in the constructor parameter with the ServiceKey annotation metadata."""
38

39
    def __init__(self) -> None:
1✔
40
        super().__init__(
1✔
41
            "The type of the key used for lookup doesn't match the type in the constructor parameter with the ServiceKey annotation metadata"
42
        )
43

44

45
@final
1✔
46
class CannotResolveServiceError(WirioError):
1✔
47
    """The exception that is thrown when a service cannot be resolved."""
48

49
    def __init__(
1✔
50
        self, parameter_type: TypedType, implementation_type: TypedType
51
    ) -> None:
52
        message = f"Unable to resolve service for type '{parameter_type}' while attempting to activate '{implementation_type}'"
1✔
53
        super().__init__(message)
1✔
54

55

56
@final
1✔
57
class CannotResolveParameterServiceFromImplementationFactoryError(WirioError):
1✔
58
    """The exception that is thrown when a service for a parameter of an implementation factory cannot be resolved."""
59

60
    def __init__(self, parameter_type: TypedType) -> None:
1✔
61
        message = f"Unable to resolve service for type '{parameter_type}' while attempting to invoke an implementation factory"
1✔
62
        super().__init__(message)
1✔
63

64

65
@final
1✔
66
class CannotResolveServiceFromEndpointError(WirioError):
1✔
67
    """The exception that is thrown when a service for a parameter of an endpoint cannot be resolved."""
68

69
    def __init__(self, parameter_type: TypedType) -> None:
1✔
70
        message = f"Unable to resolve service for type '{parameter_type}' while attempting to invoke endpoint"
1✔
71
        super().__init__(message)
1✔
72

73

74
@final
1✔
75
class NoServiceRegisteredError(WirioError):
1✔
76
    """The exception that is thrown when no service is registered for a given type."""
77

78
    def __init__(self, service_type: TypedType) -> None:
1✔
79
        message = f"No service for type '{service_type}' has been registered"
1✔
80
        super().__init__(message)
1✔
81

82

83
@final
1✔
84
class NoKeyedServiceRegisteredError(WirioError):
1✔
85
    """The exception that is thrown when no keyed service is registered for a given type and key."""
86

87
    def __init__(self, service_type: TypedType, service_key_type: type) -> None:
1✔
88
        message = f"No keyed service for type '{service_type}' using key type '{service_key_type}' has been registered"
1✔
89
        super().__init__(message)
1✔
90

91

92
@final
1✔
93
class KeyedServiceAnyKeyUsedToResolveServiceError(WirioError):
1✔
94
    """The exception that is thrown when KeyedService.AnyKey is used to resolve a single service."""
95

96
    def __init__(self) -> None:
1✔
97
        message = "KeyedService.ANY_KEY cannot be used to resolve a single service"
1✔
98
        super().__init__(message)
1✔
99

100

101
@final
1✔
102
class CircularDependencyError(WirioError):
1✔
103
    """The exception that is thrown when a circular dependency is detected."""
104

105
    def __init__(self, service_type: TypedType) -> None:
1✔
106
        message = f"A circular dependency was detected for the service of type '{service_type}'"
1✔
107
        super().__init__(message)
1✔
108

109

110
@final
1✔
111
class NoSingletonServiceRegisteredError(WirioError):
1✔
112
    """The exception that is thrown when no singleton service is registered for a given type."""
113

114
    def __init__(self, service_type: TypedType) -> None:
1✔
115
        message = f"No singleton service for type '{service_type}' has been registered"
1✔
116
        super().__init__(message)
1✔
117

118

119
@final
1✔
120
class NoKeyedSingletonServiceRegisteredError(WirioError):
1✔
121
    """The exception that is thrown when no keyed singleton service is registered for a given type and key."""
122

123
    def __init__(self, service_type: TypedType, service_key_type: type) -> None:
1✔
124
        message = f"No keyed singleton service for type '{service_type}' using key type '{service_key_type}' has been registered"
1✔
125
        super().__init__(message)
1✔
126

127

128
@final
1✔
129
class ServiceContainerAlreadyBuiltError(WirioError):
1✔
130
    """The exception that is thrown when trying to modify the ServiceContainer after it has been built."""
131

132
    def __init__(self) -> None:
1✔
NEW
133
        message = "Operation not allowed after building the ServiceContainer"
×
NEW
134
        super().__init__(message)
×
135

136

137
@final
1✔
138
class ServiceContainerNotBuiltError(WirioError):
1✔
139
    """The exception that is thrown when trying to modify the ServiceContainer before it has been built."""
140

141
    def __init__(self) -> None:
1✔
NEW
142
        message = "Operation not allowed before building the ServiceContainer"
×
NEW
143
        super().__init__(message)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc