Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions packages/controller/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ interface SendResponseToOptions {
payload: Record<string, unknown>;
}

/**
* Error class for adapter not found dependency issues
*/
class AdapterNotFoundError extends Error {}

/**
* Error class for adapter version mismatch dependency issues
*/
class AdapterVersionMismatchError extends Error {}

/** Host information including host id and running version */
type HostInformation = ioBroker.HostCommon & { host: string; runningVersion: string };

Expand Down Expand Up @@ -3283,7 +3293,7 @@ function checkVersion(name: string, version: string, instances: Record<string, i
// Check only a version
if (version) {
if (!semver.satisfies(ioPackage.common.version, version, { includePrerelease: true })) {
throw new Error(
throw new AdapterVersionMismatchError(
`Invalid version of "${name}". Installed "${ioPackage.common.version}", required "${version}"`,
);
} else {
Expand All @@ -3301,7 +3311,7 @@ function checkVersion(name: string, version: string, instances: Record<string, i
);
for (const inst of filteredInst) {
if (version && !semver.satisfies(instances[inst].common.version, version, { includePrerelease: true })) {
throw new Error(
throw new AdapterVersionMismatchError(
`required adapter "${name}" has wrong version. Installed "${instances[inst].common.version}", required "${version}"!`,
);
}
Expand All @@ -3310,7 +3320,7 @@ function checkVersion(name: string, version: string, instances: Record<string, i
}

if (!isFound) {
throw new Error(`required adapter "${name}" not found!`);
throw new AdapterNotFoundError(`required adapter "${name}" not found!`);
}
}

Expand Down Expand Up @@ -3363,7 +3373,15 @@ async function checkVersions(id: string, deps?: Dependencies, globalDeps?: Depen
}
} catch (e) {
logger.debug(`${hostLogPrefix} ${id} [globalDependency]: ${JSON.stringify(globalDeps)}`);
throw new Error(`Adapter dependency not fulfilled on any host: ${e.message}`);

if (e instanceof AdapterNotFoundError) {
throw new Error(`Adapter required by dependency not installed: ${e.message}`);
} else if (e instanceof AdapterVersionMismatchError) {
throw new Error(`Adapter dependency not fulfilled on all hosts where adapter is installed: ${e.message}`);
} else {
// fallback for any other errors
throw new Error(`Adapter dependency not fulfilled: ${e.message}`);
}
}
}

Expand Down
Loading