Skip to content

Commit

Permalink
added some more error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuenzenmeyer committed Jun 21, 2016
1 parent 2943874 commit b7797c7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
38 changes: 27 additions & 11 deletions core/lib/pattern_assembler.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,26 +154,42 @@ var pattern_assembler = function () {
//look for a json file for this template
try {
var jsonFilename = path.resolve(patternsPath, currentPattern.subdir, currentPattern.fileName + ".json");
currentPattern.jsonFileData = fs.readJSONSync(jsonFilename);
if (patternlab.config.debug) {
console.log('processPatternIterative: found pattern-specific data.json for ' + currentPattern.patternPartial);
try {
var jsonFilenameStats = fs.statSync(jsonFilename);
} catch (err) {
//not a file
}
if (jsonFilenameStats && jsonFilenameStats.isFile()) {
currentPattern.jsonFileData = fs.readJSONSync(jsonFilename);
if (patternlab.config.debug) {
console.log('processPatternIterative: found pattern-specific data.json for ' + currentPattern.patternPartial);
}
}
}
catch (e) {
// do nothing
catch (err) {
console.log('There was an error parsing sibling JSON for ' + currentPattern.relPath);
console.log(err);
}

//look for a listitems.json file for this template
try {
var listJsonFileName = path.resolve(patternsPath, currentPattern.subdir, currentPattern.fileName + ".listitems.json");
currentPattern.listitems = fs.readJSONSync(listJsonFileName);
buildListItems(currentPattern);
if (patternlab.config.debug) {
console.log('found pattern-specific listitems.json for ' + currentPattern.patternPartial);
try {
var listJsonFileStats = fs.statSync(listJsonFileName);
} catch (err) {
//not a file
}
if (listJsonFileStats && listJsonFileStats.isFile()) {
currentPattern.listitems = fs.readJSONSync(listJsonFileName);
buildListItems(currentPattern);
if (patternlab.config.debug) {
console.log('found pattern-specific listitems.json for ' + currentPattern.patternPartial);
}
}
}
catch (e) {
// do nothing
catch (err) {
console.log('There was an error parsing sibling listitem JSON for ' + currentPattern.relPath);
console.log(err);
}

//look for a markdown file for this template
Expand Down
9 changes: 7 additions & 2 deletions core/lib/pseudopattern_hunter.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ var pseudopattern_hunter = function () {
}

//we want to do everything we normally would here, except instead read the pseudoPattern data
var variantFileData = fs.readJSONSync(path.resolve(paths.source.patterns, pseudoPatterns[i]));

try {
var variantFileData = fs.readJSONSync(path.resolve(paths.source.patterns, pseudoPatterns[i]));
} catch (err) {
console.log('There was an error parsing pseudopattern JSON for ' + currentPattern.relPath);
console.log(err);
}

//extend any existing data with variant data
variantFileData = plutils.mergeData(currentPattern.jsonFileData, variantFileData);

Expand Down

0 comments on commit b7797c7

Please sign in to comment.