MCPcopy Create free account
hub / github.com/bytebase/dbhub / isDriverNotInstalled

Function isDriverNotInstalled

src/utils/module-loader.ts:12–31  ·  view source on GitHub ↗
(err: unknown, driver: string)

Source from the content-addressed store, hash-verified

10 * the driver name as a substring (e.g. "pg-connection-string" does not match "pg").
11 */
12export function isDriverNotInstalled(err: unknown, driver: string): boolean {
13 if (
14 !(err instanceof Error) ||
15 !("code" in err) ||
16 (err as NodeJS.ErrnoException).code !== "ERR_MODULE_NOT_FOUND"
17 ) {
18 return false;
19 }
20
21 const match = err.message.match(MISSING_MODULE_RE);
22 if (!match) {
23 return false;
24 }
25
26 const missingSpecifier = match[1];
27 return (
28 missingSpecifier === driver ||
29 missingSpecifier.startsWith(`${driver}/`)
30 );
31}
32
33/**
34 * Check if an error is any kind of missing module error (ESM or CJS).

Callers 5

loadConnectorsFunction · 0.85
generateRdsAuthTokenFunction · 0.85
parseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected