ServiceAlreadyRegisteredException class final

An exception thrown when an attempt is made to register a service that has already been registered in the service locator.

This exception helps maintain the integrity of the service registry by preventing accidental duplication of service registrations.

Usage: Throws when trying to register a service with the same type more than once.

void registerSingleton<T extends Object>(T instance) {
  if (locator.isRegistered<T>()) {
    throw ServiceAlreadyRegisteredException(T);
  }
  locator._services[T] = instance;
}
Implemented types

Constructors

ServiceAlreadyRegisteredException.new(Type serviceType, [String? serviceName])
Constructs a ServiceAlreadyRegisteredException with the serviceType that was attempted to be registered more than once.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serviceName String?
The name of the service that caused the exception, if any.
final
serviceType Type
The type of the service that caused the exception.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited