Skip to content

Commit 7708c4c

Browse files
fatbasstardChuck Meyer
authored andcommitted
Add better error handling if cfn-lint is not installed (#10)
* Add better error handling if cfn-lint is not installed
1 parent 5c46343 commit 7708c4c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ For example if there is an image subfolder under your extension project workspac
1212

1313
## Requirements
1414

15-
Requires cfn-lint to be installed. `pip install cfn-lint`
15+
Requires cfn-lint to be installed: `pip install cfn-lint`
16+
17+
More information about cfn-lint can be found [here](https://github.com/awslabs/cfn-python-lint)
1618

1719
## Extension Settings
1820

1921
* `cfnLint.path`: path to the cfn-lint command
2022
* `cfnLint.appendRules`: Array of paths containing additional Rules
2123
* `cfnLint.ignoreRules`: Array of Rule Ids to be ignored
22-
* `cfnLint.overrideSpecPath`: Path to an Specification overrule file
24+
* `cfnLint.overrideSpecPath`: Path to an Specification overrule file

server/src/server.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,21 @@ function validateCloudFormationFile(document: TextDocument): void {
165165
let start = 0;
166166
let end = Number.MAX_VALUE;
167167

168+
child.on('error', function(err) {
169+
let errorMessage = `Unable to start cfn-lint (${err}). Is cfn-lint installed correctly?`;
170+
connection.console.log(errorMessage);
171+
let lineNumber = 0;
172+
let diagnostic: Diagnostic = {
173+
range: {
174+
start: { line: lineNumber, character: start },
175+
end: { line: lineNumber, character: end }
176+
},
177+
severity: DiagnosticSeverity.Error,
178+
message: errorMessage
179+
};
180+
diagnostics.push(diagnostic);
181+
});
182+
168183
child.stderr.on("data", (data: Buffer) => {
169184
let err = data.toString();
170185
connection.console.log(err);

0 commit comments

Comments
 (0)