1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-05 09:56:22 +00:00

Tweak error handling for cmd params.

This commit is contained in:
hacksalot 2016-01-01 15:06:16 -05:00
parent 5a2d892b85
commit 2b669cf35c
2 changed files with 12 additions and 2 deletions

View File

@ -88,17 +88,27 @@ Definition of the ResumeFactory class.
// TODO: Core should not log
log( chalk.gray('Reading resume: ') + chalk.cyan.bold(fileName) );
// Read the file
rawData = FS.readFileSync( fileName, 'utf8' );
// Parse it to JSON
return {
json: JSON.parse( rawData )
};
}
catch(ex) {
catch( ex ) {
// If FS.readFileSync threw, pass the exception along.
if (!rawData)
throw ex;
// Otherwise if JSON.parse failed: probably a SyntaxError.
return {
error: ex,
raw: rawData
};
}
}

View File

@ -35,8 +35,8 @@ catch( ex ) {
function main() {
// Setup
if( process.argv.length <= 2 ) { throw { fluenterror: 4 }; }
var a = ARGS( process.argv.slice(2) );
if( a._.length === 0 ) { throw { fluenterror: 4 }; }
opts = getOpts( a );
logMsg( title );