@@ -139,15 +139,28 @@ export enum CliConfigErrorCategory {
139139 PackMissingAuth = "PackMissingAuth" ,
140140 SwiftBuildFailed = "SwiftBuildFailed" ,
141141 UnsupportedBuildMode = "UnsupportedBuildMode" ,
142+ UnsupportedPlatform = "UnsupportedPlatform" ,
142143}
143144
144145type CliErrorConfiguration = {
145- /** One of these candidates, or the exit code, must be present in the error message. */
146+ /** One of these candidates, or the exit code, must be present in the error message.
147+ * If present, precondition as well must hold
148+ */
146149 cliErrorMessageCandidates : RegExp [ ] ;
147150 exitCode ?: number ;
148151 additionalErrorMessageToAppend ?: string ;
152+ precondition ?: ( ) => boolean ;
149153} ;
150154
155+ function isUnsupportedPlatform ( ) : boolean {
156+ return ! [
157+ [ "linux" , "x64" ] ,
158+ [ "win32" , "x64" ] ,
159+ [ "darwin" , "arm64" ] ,
160+ [ "darwin" , "x64" ] ,
161+ ] . some ( ( [ p , a ] ) => p === process . platform && a === process . arch ) ;
162+ }
163+
151164/**
152165 * All of our caught CLI error messages that we handle specially: ie. if we
153166 * would like to categorize an error as a configuration error or not.
@@ -156,6 +169,13 @@ export const cliErrorsConfig: Record<
156169 CliConfigErrorCategory ,
157170 CliErrorConfiguration
158171> = {
172+ // if running on an unsupported platform, use this blanket category for all errors
173+ [ CliConfigErrorCategory . UnsupportedPlatform ] : {
174+ cliErrorMessageCandidates : [ new RegExp ( "" ) ] ,
175+ precondition : isUnsupportedPlatform ,
176+ additionalErrorMessageToAppend :
177+ "This platform and architecture are not supported by the CodeQL CLI. See https://codeql.github.com/docs/codeql-overview/system-requirements" ,
178+ } ,
159179 [ CliConfigErrorCategory . AutobuildError ] : {
160180 cliErrorMessageCandidates : [
161181 new RegExp ( "We were unable to automatically build your code" ) ,
@@ -298,6 +318,9 @@ export function getCliConfigCategoryIfExists(
298318 cliError : CliError ,
299319) : CliConfigErrorCategory | undefined {
300320 for ( const [ category , configuration ] of Object . entries ( cliErrorsConfig ) ) {
321+ if ( configuration . precondition && ! configuration . precondition ( ) ) {
322+ continue ;
323+ }
301324 if (
302325 cliError . exitCode !== undefined &&
303326 configuration . exitCode !== undefined &&
0 commit comments