mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 10:21:55 +00:00
chore: Better error message
This commit is contained in:
@@ -13,9 +13,10 @@ type Daemon<Ids extends string, Command extends string, Id extends string> = {
|
||||
fn: () => Promise<CheckResult> | CheckResult
|
||||
trigger?: Trigger
|
||||
}
|
||||
requires?: Exclude<Ids, Id>[]
|
||||
requires: Exclude<Ids, Id>[]
|
||||
}
|
||||
|
||||
type ErrorDuplicateId<Id extends string> = `The id ${Id} is already used`
|
||||
/**
|
||||
* Used during the main of a function, it allows us to describe and ensure a set of daemons are running.
|
||||
* With the dependency, we are using this like an init system, where we can ensure that a daemon is running
|
||||
@@ -56,7 +57,12 @@ export class Daemons<Ids extends string> {
|
||||
return new Daemons<never>(config.effects, config.started)
|
||||
}
|
||||
addDaemon<Id extends string, Command extends string>(
|
||||
id: "" extends Id ? never : Id extends Ids ? never : Id,
|
||||
// prettier-ignore
|
||||
id:
|
||||
"" extends Id ? never :
|
||||
ErrorDuplicateId<Id> extends Id ? never :
|
||||
Id extends Ids ? ErrorDuplicateId<Id> :
|
||||
Id,
|
||||
newDaemon: Omit<Daemon<Ids, Command, Id>, "id">,
|
||||
) {
|
||||
const daemons = ((this?.daemons ?? []) as any[]).concat({
|
||||
@@ -98,7 +104,6 @@ export class Daemons<Ids extends string> {
|
||||
}
|
||||
resolve(child)
|
||||
})
|
||||
return child
|
||||
})
|
||||
}
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user