1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-22 08:20:11 +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')
, FS = require('fs')
, FCMD = require('../hackmyapi')

View File

@ -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 ); });

View File

@ -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
};

View File

@ -22,7 +22,9 @@ Status codes for HackMyResume.
invalidFormat: 12,
notOnPath: 13,
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;
// "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 } );
}
}

View File

@ -17,6 +17,6 @@ try {
}
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 );
}
catch( ex ) {
require('../src/core/error-handler').err( ex, false );
require('../src/cli/error-handler').err( ex, false );
}
CHALK.enabled = true;
process.exit = ProcessExitOrg;