* refactor: start refactor of pyro servers module-based class * refactor: finish modules * refactor: start on type checking + matching api * refactor: finish pyro servers composable refactor * refactor: pyro -> modrinth * fix: import not refactored * fix: broken power action enums * fix: remove pyro mentions * fix: lint * refactor: fix option pages * fix: error renames * remove empty pyro-servers.ts file --------- Signed-off-by: IMB11 <hendersoncal117@gmail.com> Co-authored-by: Prospector <prospectordev@gmail.com>
28 lines
708 B
TypeScript
28 lines
708 B
TypeScript
export class ModrinthServersMultiError extends Error {
|
|
public readonly errors: Map<string, Error> = new Map()
|
|
public readonly timestamp: number = Date.now()
|
|
|
|
constructor(message?: string) {
|
|
super(message || 'Multiple errors occurred')
|
|
this.name = 'MultipleErrors'
|
|
}
|
|
|
|
addError(module: string, error: Error) {
|
|
this.errors.set(module, error)
|
|
this.message = this.buildErrorMessage()
|
|
}
|
|
|
|
hasErrors() {
|
|
return this.errors.size > 0
|
|
}
|
|
|
|
private buildErrorMessage(): string {
|
|
return (
|
|
Array.from(this.errors.entries())
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
.map(([_module, error]) => error.message)
|
|
.join('\n')
|
|
)
|
|
}
|
|
}
|