diff --git a/src/core/error-handler.js b/src/cli/error-handler.js similarity index 99% rename from src/core/error-handler.js rename to src/cli/error-handler.js index c89f0f1..42cdeee 100644 --- a/src/core/error-handler.js +++ b/src/cli/error-handler.js @@ -10,7 +10,7 @@ Error-handling routines for HackMyResume. - var HACKMYSTATUS = require('./status-codes') + var HACKMYSTATUS = require('../core/status-codes') , PKG = require('../../package.json') , FS = require('fs') , FCMD = require('../hackmyapi') diff --git a/src/cli/main.js b/src/cli/main.js index cfaacbd..d82ea0c 100644 --- a/src/cli/main.js +++ b/src/cli/main.js @@ -194,7 +194,7 @@ Definition of the `main` function. function execute( src, dst, opts, log ) { loadOptions.call( this, opts, this.parent.jsonArgs ); - require( '../core/error-handler' ).init( _opts.debug ); + require( './error-handler' ).init( _opts.debug ); var out = new OUTPUT( _opts ); var v = new HMR.verbs[ this.name() ](); v.on( 'hmr:status', function() { out.do.apply( out, arguments ); }); diff --git a/src/core/event-codes.js b/src/core/event-codes.js index 13c0e2d..0486c6b 100644 --- a/src/core/event-codes.js +++ b/src/core/event-codes.js @@ -12,41 +12,27 @@ Event code definitions. module.exports = { - unknown: 0, - unk: 0, - - begin: 1, - end: 2, - - beforeRead: 3, - afterRead: 4, - - beforeCreate: 5, - bc: 5, - - afterCreate: 6, - ac: 6, - - beforeTheme: 7, - afterTheme: 8, - - beforeMerge: 9, - afterMerge: 10, - - beforeGenerate: 11, - afterGenerate: 12, - - beforeAnalyze: 13, - afterAnalyze: 14, - - beforeConvert: 15, - afterConvert: 16, - - verifyOutputs: 17, - - beforeParse: 18, - afterParse: 19 - + error: -1, + success: 0, + begin: 1, + end: 2, + beforeRead: 3, + afterRead: 4, + beforeCreate: 5, + afterCreate: 6, + beforeTheme: 7, + afterTheme: 8, + beforeMerge: 9, + afterMerge: 10, + beforeGenerate: 11, + afterGenerate: 12, + beforeAnalyze: 13, + afterAnalyze: 14, + beforeConvert: 15, + afterConvert: 16, + verifyOutputs: 17, + beforeParse: 18, + afterParse: 19 }; diff --git a/src/core/status-codes.js b/src/core/status-codes.js index 42d1857..be82e6b 100644 --- a/src/core/status-codes.js +++ b/src/core/status-codes.js @@ -22,7 +22,9 @@ Status codes for HackMyResume. invalidFormat: 12, notOnPath: 13, readError: 14, - parseError: 15 + parseError: 15, + fileSaveError: 16, + generateError: 17 }; }()); diff --git a/src/generators/template-generator.js b/src/generators/template-generator.js index e38419f..4dd3580 100644 --- a/src/generators/template-generator.js +++ b/src/generators/template-generator.js @@ -141,6 +141,7 @@ Definition of the TemplateGenerator class. TODO: Refactor var that = this; // "Generate": process individual files within the theme + // TODO: refactor genInfo.files.forEach(function( file ){ var thisFilePath; @@ -168,9 +169,9 @@ Definition of the TemplateGenerator class. TODO: Refactor that.onAfterSave && that.onAfterSave( { outputFile: fileName, mk: file.data, opts: that.opts } ); } - catch(ex) { - console.log(ex); - require('../core/error-handler').err(ex, false); + catch( ex ) { + that.stat( HME.error, ex.fluenterrror || + { fluenterror: HACKMYSTATUS.fileSaveError, inner: ex } ); } } else if( file.info.action === null/* && theme.explicit*/ ) { @@ -179,10 +180,9 @@ Definition of the TemplateGenerator class. TODO: Refactor MKDIRP.sync( PATH.dirname(thisFilePath) ); FS.copySync( file.info.path, thisFilePath ); } - catch(ex) { - console.log('B'); - ex.showStack = true; - require('../core/error-handler').err( ex ); + catch( ex ) { + that.stat( HME.error, ex.fluenterrror || + { fluenterror: HACKMYSTATUS.fileSaveError, inner: ex } ); } } }); @@ -281,8 +281,8 @@ Definition of the TemplateGenerator class. TODO: Refactor theme ); } catch(ex) { - ex.showStack = true; - require('../core/error-handler').err( ex ); + that.stat( HME.error, ex.fluenterrror || + { fluenterror: HACKMYSTATUS.generateError, inner: ex } ); } } diff --git a/src/index.js b/src/index.js index bcef218..0d6b72f 100644 --- a/src/index.js +++ b/src/index.js @@ -17,6 +17,6 @@ try { } catch( ex ) { - require('./core/error-handler').err( ex, true ); + require('./cli/error-handler').err( ex, true ); } diff --git a/test/test-stdout.js b/test/test-stdout.js index 935a5ff..7092808 100644 --- a/test/test-stdout.js +++ b/test/test-stdout.js @@ -37,7 +37,7 @@ describe('Testing Ouput interface', function () { HMRMAIN( args ); } catch( ex ) { - require('../src/core/error-handler').err( ex, false ); + require('../src/cli/error-handler').err( ex, false ); } CHALK.enabled = true; process.exit = ProcessExitOrg;