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

Move error handling out of core.

This commit is contained in:
hacksalot 2016-01-13 15:28:02 -05:00
parent eddda8146e
commit 19b30d55ec
7 changed files with 37 additions and 49 deletions

View File

@ -10,7 +10,7 @@ Error-handling routines for HackMyResume.
var HACKMYSTATUS = require('./status-codes') var HACKMYSTATUS = require('../core/status-codes')
, PKG = require('../../package.json') , PKG = require('../../package.json')
, FS = require('fs') , FS = require('fs')
, FCMD = require('../hackmyapi') , FCMD = require('../hackmyapi')

View File

@ -194,7 +194,7 @@ Definition of the `main` function.
function execute( src, dst, opts, log ) { function execute( src, dst, opts, log ) {
loadOptions.call( this, opts, this.parent.jsonArgs ); 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 out = new OUTPUT( _opts );
var v = new HMR.verbs[ this.name() ](); var v = new HMR.verbs[ this.name() ]();
v.on( 'hmr:status', function() { out.do.apply( out, arguments ); }); v.on( 'hmr:status', function() { out.do.apply( out, arguments ); });

View File

@ -12,41 +12,27 @@ Event code definitions.
module.exports = { module.exports = {
unknown: 0, error: -1,
unk: 0, success: 0,
begin: 1,
begin: 1, end: 2,
end: 2, beforeRead: 3,
afterRead: 4,
beforeRead: 3, beforeCreate: 5,
afterRead: 4, afterCreate: 6,
beforeTheme: 7,
beforeCreate: 5, afterTheme: 8,
bc: 5, beforeMerge: 9,
afterMerge: 10,
afterCreate: 6, beforeGenerate: 11,
ac: 6, afterGenerate: 12,
beforeAnalyze: 13,
beforeTheme: 7, afterAnalyze: 14,
afterTheme: 8, beforeConvert: 15,
afterConvert: 16,
beforeMerge: 9, verifyOutputs: 17,
afterMerge: 10, beforeParse: 18,
afterParse: 19
beforeGenerate: 11,
afterGenerate: 12,
beforeAnalyze: 13,
afterAnalyze: 14,
beforeConvert: 15,
afterConvert: 16,
verifyOutputs: 17,
beforeParse: 18,
afterParse: 19
}; };

View File

@ -22,7 +22,9 @@ Status codes for HackMyResume.
invalidFormat: 12, invalidFormat: 12,
notOnPath: 13, notOnPath: 13,
readError: 14, readError: 14,
parseError: 15 parseError: 15,
fileSaveError: 16,
generateError: 17
}; };
}()); }());

View File

@ -141,6 +141,7 @@ Definition of the TemplateGenerator class. TODO: Refactor
var that = this; var that = this;
// "Generate": process individual files within the theme // "Generate": process individual files within the theme
// TODO: refactor
genInfo.files.forEach(function( file ){ genInfo.files.forEach(function( file ){
var thisFilePath; var thisFilePath;
@ -168,9 +169,9 @@ Definition of the TemplateGenerator class. TODO: Refactor
that.onAfterSave && that.onAfterSave( that.onAfterSave && that.onAfterSave(
{ outputFile: fileName, mk: file.data, opts: that.opts } ); { outputFile: fileName, mk: file.data, opts: that.opts } );
} }
catch(ex) { catch( ex ) {
console.log(ex); that.stat( HME.error, ex.fluenterrror ||
require('../core/error-handler').err(ex, false); { fluenterror: HACKMYSTATUS.fileSaveError, inner: ex } );
} }
} }
else if( file.info.action === null/* && theme.explicit*/ ) { else if( file.info.action === null/* && theme.explicit*/ ) {
@ -179,10 +180,9 @@ Definition of the TemplateGenerator class. TODO: Refactor
MKDIRP.sync( PATH.dirname(thisFilePath) ); MKDIRP.sync( PATH.dirname(thisFilePath) );
FS.copySync( file.info.path, thisFilePath ); FS.copySync( file.info.path, thisFilePath );
} }
catch(ex) { catch( ex ) {
console.log('B'); that.stat( HME.error, ex.fluenterrror ||
ex.showStack = true; { fluenterror: HACKMYSTATUS.fileSaveError, inner: ex } );
require('../core/error-handler').err( ex );
} }
} }
}); });
@ -281,8 +281,8 @@ Definition of the TemplateGenerator class. TODO: Refactor
theme ); theme );
} }
catch(ex) { catch(ex) {
ex.showStack = true; that.stat( HME.error, ex.fluenterrror ||
require('../core/error-handler').err( ex ); { fluenterror: HACKMYSTATUS.generateError, inner: ex } );
} }
} }

View File

@ -17,6 +17,6 @@ try {
} }
catch( ex ) { catch( ex ) {
require('./core/error-handler').err( ex, true ); require('./cli/error-handler').err( ex, true );
} }

View File

@ -37,7 +37,7 @@ describe('Testing Ouput interface', function () {
HMRMAIN( args ); HMRMAIN( args );
} }
catch( ex ) { catch( ex ) {
require('../src/core/error-handler').err( ex, false ); require('../src/cli/error-handler').err( ex, false );
} }
CHALK.enabled = true; CHALK.enabled = true;
process.exit = ProcessExitOrg; process.exit = ProcessExitOrg;