Skip to content

Commit e62ee58

Browse files
committed
Convert "Invalid source root" errors to UserErrors
1 parent 4cf8004 commit e62ee58

File tree

3 files changed

+69
-34
lines changed

3 files changed

+69
-34
lines changed

lib/init.js

Lines changed: 31 additions & 15 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: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,7 @@ export async function runInit(
117117
}
118118
}
119119
} catch (e) {
120-
// Handle the situation where init is called twice
121-
// for the same database in the same job.
122-
if (
123-
e instanceof Error &&
124-
e.message?.includes("Refusing to create databases") &&
125-
e.message.includes("exists and is not an empty directory.")
126-
) {
127-
throw new util.UserError(
128-
`Is the "init" action called twice in the same job? ${e.message}`
129-
);
130-
} else if (
131-
e instanceof Error &&
132-
e.message?.includes("is not compatible with this CodeQL CLI")
133-
) {
134-
throw new util.UserError(e.message);
135-
} else {
136-
throw e;
137-
}
120+
throw processError(e);
138121
}
139122
return await getCombinedTracerConfig(
140123
config,
@@ -144,6 +127,42 @@ export async function runInit(
144127
);
145128
}
146129

130+
/**
131+
* Possibly convert this error into a UserError in order to avoid
132+
* counting this error towards our internal error budget.
133+
*
134+
* @param e The error to possibly convert to a UserError.
135+
*
136+
* @returns A UserError if the error is a known error that can be
137+
* attributed to the user, otherwise the original error.
138+
*/
139+
function processError(e: any): Error {
140+
if (!(e instanceof Error)) {
141+
return e;
142+
}
143+
144+
if (
145+
// Init action called twice
146+
e.message?.includes("Refusing to create databases") &&
147+
e.message.includes("exists and is not an empty directory.")
148+
) {
149+
return new util.UserError(
150+
`Is the "init" action called twice in the same job? ${e.message}`
151+
);
152+
}
153+
154+
if (
155+
// Version of CodeQL CLI is incompatible with this version of the CodeQL Action
156+
e.message?.includes("is not compatible with this CodeQL CLI") ||
157+
// Expected source location for database creation does not exist
158+
e.message?.includes("Invalid source root")
159+
) {
160+
return new util.UserError(e.message);
161+
}
162+
163+
return e;
164+
}
165+
147166
// Runs a powershell script to inject the tracer into a parent process
148167
// so it can tracer future processes, hopefully including the build process.
149168
// If processName is given then injects into the nearest parent process with

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