mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 13:29:02 +08:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import { DEFAULT_SERVICE_VARIANT } from './consts.js';
|
||||
import type { ServiceIdentifierValue } from './types.js';
|
||||
|
||||
export class RecursionLimitError extends Error {
|
||||
constructor() {
|
||||
super('Dynamic resolve recursion limit reached');
|
||||
}
|
||||
}
|
||||
|
||||
export class CircularDependencyError extends Error {
|
||||
constructor(readonly dependencyStack: ServiceIdentifierValue[]) {
|
||||
super(
|
||||
`A circular dependency was detected.\n` +
|
||||
stringifyDependencyStack(dependencyStack)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class ServiceNotFoundError extends Error {
|
||||
constructor(readonly identifier: ServiceIdentifierValue) {
|
||||
super(`Service ${stringifyIdentifier(identifier)} not found in container`);
|
||||
}
|
||||
}
|
||||
|
||||
export class MissingDependencyError extends Error {
|
||||
constructor(
|
||||
readonly from: ServiceIdentifierValue,
|
||||
readonly target: ServiceIdentifierValue,
|
||||
readonly dependencyStack: ServiceIdentifierValue[]
|
||||
) {
|
||||
super(
|
||||
`Missing dependency ${stringifyIdentifier(
|
||||
target
|
||||
)} in creating service ${stringifyIdentifier(
|
||||
from
|
||||
)}.\n${stringifyDependencyStack(dependencyStack)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class DuplicateServiceDefinitionError extends Error {
|
||||
constructor(readonly identifier: ServiceIdentifierValue) {
|
||||
super(`Service ${stringifyIdentifier(identifier)} already exists`);
|
||||
}
|
||||
}
|
||||
|
||||
function stringifyIdentifier(identifier: ServiceIdentifierValue) {
|
||||
return `[${identifier.identifierName}]${
|
||||
identifier.variant !== DEFAULT_SERVICE_VARIANT
|
||||
? `(${identifier.variant})`
|
||||
: ''
|
||||
}`;
|
||||
}
|
||||
|
||||
function stringifyDependencyStack(dependencyStack: ServiceIdentifierValue[]) {
|
||||
return dependencyStack
|
||||
.map(identifier => `${stringifyIdentifier(identifier)}`)
|
||||
.join(' -> ');
|
||||
}
|
||||
Reference in New Issue
Block a user