Skip to content

Commit

Permalink
add appropiate error message when error parse toml
Browse files Browse the repository at this point in the history
  • Loading branch information
fadingNA committed Oct 2, 2024
1 parent fc3498f commit 5b17dd2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/file_functions/getTOMLFileValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ const __homeDir = os.homedir();
export default function getTOMLFileValues() {
const tomlFile = path.join(__homeDir, '.gimme_readme_config');

if (!fs.existsSync(tomlFile)) return null;

try {
const configContent = fs.readFileSync(tomlFile, 'utf-8');
const tomlParser = parseTOML(configContent);
const config = getStaticTOMLValue(tomlParser);
return config;
} catch (err) {
} catch (error) {
console.error(
`Error at handleConfigOption when system is reading TOML at ${tomlFile} with error ${err}`
`Error parsing .gimme_readme_config. File is not formatted using TOML syntax: ${error}`
);
return null;
process.exit(1);
}
}

0 comments on commit 5b17dd2

Please sign in to comment.