@@ -294,7 +294,7 @@ export const cliErrorsConfig: Record<
294
294
* the error messages in the config record, or the exit codes match, return the error category;
295
295
* if not, return undefined.
296
296
*/
297
- export function getCliConfigCategoryIfExists (
297
+ function getCliConfigCategoryIfExists (
298
298
cliError : CliError ,
299
299
) : CliConfigErrorCategory | undefined {
300
300
for ( const [ category , configuration ] of Object . entries ( cliErrorsConfig ) ) {
@@ -317,11 +317,45 @@ export function getCliConfigCategoryIfExists(
317
317
}
318
318
319
319
/**
320
- * Changes an error received from the CLI to a ConfigurationError with optionally an extra
321
- * error message appended, if it exists in a known set of configuration errors. Otherwise,
320
+ * Check if we are running on an unsupported platform/architecture combination.
321
+ * If so, return a ConfigurationError with a message that explains that, mentioning
322
+ * the underlying `cliError`. Otherwise, reutrn `undefined`.
323
+ */
324
+ function getUnsupportedPlatformError (
325
+ cliError : CliError ,
326
+ ) : ConfigurationError | undefined {
327
+ if (
328
+ ! [
329
+ [ "linux" , "x64" ] ,
330
+ [ "win32" , "x64" ] ,
331
+ [ "darwin" , "x64" ] ,
332
+ [ "darwin" , "arm64" ] ,
333
+ ] . some (
334
+ ( [ platform , arch ] ) =>
335
+ platform === process . platform && arch === process . arch ,
336
+ )
337
+ ) {
338
+ return new ConfigurationError (
339
+ "The CodeQL CLI does not support the platform/architecture combination of " +
340
+ `${ process . platform } /${ process . arch } ` +
341
+ "(see https://codeql.github.com/docs/codeql-overview/system-requirements). " +
342
+ `The underlying error was: ${ cliError . message } ` ,
343
+ ) ;
344
+ }
345
+ return undefined ;
346
+ }
347
+
348
+ /**
349
+ * Changes an error received from the CLI to a ConfigurationError with the message
350
+ * optionally being transformed, if it is a known configuration error. Otherwise,
322
351
* simply returns the original error.
323
352
*/
324
353
export function wrapCliConfigurationError ( cliError : CliError ) : Error {
354
+ const unsupportedPlatformError = getUnsupportedPlatformError ( cliError ) ;
355
+ if ( unsupportedPlatformError !== undefined ) {
356
+ return unsupportedPlatformError ;
357
+ }
358
+
325
359
const cliConfigErrorCategory = getCliConfigCategoryIfExists ( cliError ) ;
326
360
if ( cliConfigErrorCategory === undefined ) {
327
361
return cliError ;
0 commit comments