mirror of
https://github.com/pockethost/pockethost.git
synced 2025-06-14 18:16:42 +00:00
chore: warn on service reinitialization rather than throw
This commit is contained in:
parent
c72857c885
commit
771fb00d62
@ -9,12 +9,12 @@ export function mkSingleton<TConfig, TInstance>(
|
|||||||
|
|
||||||
return (config?: TConfig): TInstance => {
|
return (config?: TConfig): TInstance => {
|
||||||
if (instance && config) {
|
if (instance && config) {
|
||||||
console.error(new Error().stack)
|
console.warn('Attempted to initialize service twice.')
|
||||||
throw new Error('Attempted to initialize service twice.')
|
console.warn(new Error().stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!instance && !config) {
|
if (!instance && !config) {
|
||||||
console.error(new Error().stack)
|
console.warn(new Error().stack)
|
||||||
throw new Error('Attempted to use service before initialization.')
|
throw new Error('Attempted to use service before initialization.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user