@@ -139,15 +139,28 @@ export enum CliConfigErrorCategory {
139
139
PackMissingAuth = "PackMissingAuth" ,
140
140
SwiftBuildFailed = "SwiftBuildFailed" ,
141
141
UnsupportedBuildMode = "UnsupportedBuildMode" ,
142
+ UnsupportedPlatform = "UnsupportedPlatform" ,
142
143
}
143
144
144
145
type 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
+ */
146
149
cliErrorMessageCandidates : RegExp [ ] ;
147
150
exitCode ?: number ;
148
151
additionalErrorMessageToAppend ?: string ;
152
+ precondition ?: ( ) => boolean ;
149
153
} ;
150
154
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
+
151
164
/**
152
165
* All of our caught CLI error messages that we handle specially: ie. if we
153
166
* would like to categorize an error as a configuration error or not.
@@ -156,6 +169,13 @@ export const cliErrorsConfig: Record<
156
169
CliConfigErrorCategory ,
157
170
CliErrorConfiguration
158
171
> = {
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
+ } ,
159
179
[ CliConfigErrorCategory . AutobuildError ] : {
160
180
cliErrorMessageCandidates : [
161
181
new RegExp ( "We were unable to automatically build your code" ) ,
@@ -298,6 +318,9 @@ export function getCliConfigCategoryIfExists(
298
318
cliError : CliError ,
299
319
) : CliConfigErrorCategory | undefined {
300
320
for ( const [ category , configuration ] of Object . entries ( cliErrorsConfig ) ) {
321
+ if ( configuration . precondition && ! configuration . precondition ( ) ) {
322
+ continue ;
323
+ }
301
324
if (
302
325
cliError . exitCode !== undefined &&
303
326
configuration . exitCode !== undefined &&
0 commit comments