Skip to content

Commit 51126e5

Browse files
committed
Include better error message
When users call init multiple times.
1 parent c0b507e commit 51126e5

File tree

3 files changed

+55
-25
lines changed

3 files changed

+55
-25
lines changed

lib/init.js

Lines changed: 22 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/init.ts

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,26 +91,41 @@ export async function runInit(
9191
): Promise<TracerConfig | undefined> {
9292
fs.mkdirSync(config.dbLocation, { recursive: true });
9393

94-
if (await codeQlVersionAbove(codeql, CODEQL_VERSION_NEW_TRACING)) {
95-
// Init a database cluster
96-
await codeql.databaseInitCluster(
97-
config.dbLocation,
98-
config.languages,
99-
sourceRoot,
100-
processName,
101-
processLevel
102-
);
103-
} else {
104-
for (const language of config.languages) {
105-
// Init language database
106-
await codeql.databaseInit(
107-
util.getCodeQLDatabasePath(config, language),
108-
language,
109-
sourceRoot
94+
try {
95+
if (await codeQlVersionAbove(codeql, CODEQL_VERSION_NEW_TRACING)) {
96+
// Init a database cluster
97+
await codeql.databaseInitCluster(
98+
config.dbLocation,
99+
config.languages,
100+
sourceRoot,
101+
processName,
102+
processLevel
103+
);
104+
} else {
105+
for (const language of config.languages) {
106+
// Init language database
107+
await codeql.databaseInit(
108+
util.getCodeQLDatabasePath(config, language),
109+
language,
110+
sourceRoot
111+
);
112+
}
113+
}
114+
} catch (e) {
115+
// Handle the situation where init is called twice
116+
// for the same database in the same job.
117+
if (
118+
e instanceof Error &&
119+
e.message?.includes("Refusing to create databases") &&
120+
e.message.includes("exists and is not an empty directory.")
121+
) {
122+
throw new Error(
123+
`Is the "init" action called twice in the same job? ${e.message}`
110124
);
125+
} else {
126+
throw e;
111127
}
112128
}
113-
114129
return await getCombinedTracerConfig(config, codeql);
115130
}
116131

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy