@@ -39,11 +39,12 @@ export class GGShieldResolver {
39
39
) ;
40
40
return ;
41
41
} catch ( error ) {
42
+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
42
43
this . channel . appendLine (
43
- `Failed to use ggshield version ${ this . configuration . ggshieldPath } . `
44
+ `${ errorMessage } `
44
45
) ;
45
46
window . showErrorMessage (
46
- `Failed to use ggshield. `
47
+ `${ errorMessage } `
47
48
) ;
48
49
throw error ;
49
50
}
@@ -57,30 +58,27 @@ export class GGShieldResolver {
57
58
async testConfiguration (
58
59
configuration : GGShieldConfiguration
59
60
) : Promise < void > {
60
- let proc = runGGShieldCommand ( configuration , [ "--version " ] ) ;
61
+ let proc = runGGShieldCommand ( configuration , [ "quota " ] ) ;
61
62
if ( proc . error || proc . stderr . length > 0 ) {
63
+ if ( proc . error ) {
64
+ if ( proc . error . message . includes ( "ENOENT" ) ) {
65
+ throw new Error (
66
+ `GGShield path provided in settings is invalid: ${ configuration . ggshieldPath } .`
67
+ ) ;
68
+ } else {
69
+ throw new Error ( proc . error . message ) ;
70
+ }
71
+ } else if ( proc . stderr . includes ( "Invalid API key" ) ) {
72
+ throw new Error (
73
+ `API key provided in settings is invalid.`
74
+ ) ;
75
+ }
62
76
throw new Error (
63
- `Configuration provided in settings is invalid: ${ proc . error } `
77
+ `Configuration provided in settings is invalid: ${ proc . stderr } `
64
78
) ;
65
79
} else {
66
80
this . configuration = configuration ;
67
81
return ;
68
82
}
69
83
}
70
-
71
- /**
72
- * Tries the default bundled version of ggshield.
73
- *
74
- * @returns {Promise<void> } A promise that resolves if the configuration is valid.
75
- */
76
- private async checkBundledGGShield ( ) : Promise < void > {
77
- let proc = runGGShieldCommand ( this . configuration , [ "--version" ] ) ;
78
- if ( proc . error || proc . stderr . length > 0 ) {
79
- throw new Error (
80
- `ggshield binary not found, architecture not supported: ${ proc . error } `
81
- ) ;
82
- } else {
83
- return ;
84
- }
85
- }
86
84
}
0 commit comments