Skip to content

Commit

Permalink
feat: catch config errors #88
Browse files Browse the repository at this point in the history
  • Loading branch information
vknabel committed Nov 21, 2024
1 parent a53a4ca commit a7ba748
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/SwiftLintConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ export class SwiftLintConfig {
const configData = await promisify(readFile)(configPath, {
encoding: "utf8",
});
const config: SwiftLintConfigData = YAML.parse(configData);
return new SwiftLintConfig(configPath, config);
try {
const config: SwiftLintConfigData = YAML.parse(configData);
return new SwiftLintConfig(configPath, config);
} catch (error) {
Current.editor.showWarningMessage(
`Failed to parse SwiftLint configuration at ${configPath}: ${error}`
);
return new SwiftLintConfig(configPath, null);
}
}

private readonly config: SwiftLintConfigData;
Expand Down

0 comments on commit a7ba748

Please sign in to comment.