1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-10 07:47:07 +01:00

Reconnect process exit codes.

This commit is contained in:
hacksalot
2016-01-18 20:06:45 -05:00
parent 23cd52885b
commit 2f628f8564
9 changed files with 46 additions and 25 deletions

View File

@ -42,7 +42,7 @@ Implementation of the 'analyze' verb for HackMyResume.
*/
function analyze( sources, dst, opts ) {
if( !sources || !sources.length )
throw { fluenterror: HMSTATUS.resumeNotFound };
throw { fluenterror: HMSTATUS.resumeNotFound, quit: true };
var nlzrs = _loadInspectors();
@ -50,7 +50,10 @@ Implementation of the 'analyze' verb for HackMyResume.
var result = ResumeFactory.loadOne( src, {
format: 'FRESH', objectify: true
}, this);
result.fluenterror || _analyze.call(this, result, nlzrs, opts );
if( result.fluenterror )
this.setError( result.fluenterror, result );
else
_analyze.call(this, result, nlzrs, opts );
}, this);
}

View File

@ -62,7 +62,9 @@ Implementation of the 'build' verb for HackMyResume.
*/
function build( src, dst, opts ) {
if( !src || !src.length ) { this.err( HMSTATUS.resumeNotFound ); }
if( !src || !src.length ) {
this.err( HMSTATUS.resumeNotFound, { quit: true } );
}
prep( src, dst, opts );

View File

@ -40,20 +40,20 @@ Implementation of the 'convert' verb for HackMyResume.
function convert( srcs, dst, opts ) {
// Housekeeping
if( !srcs || !srcs.length ) { throw { fluenterror: 6 }; }
if( !srcs || !srcs.length ) { throw { fluenterror: 6, quit: true }; }
if( !dst || !dst.length ) {
if( srcs.length === 1 ) {
throw { fluenterror: HMSTATUS.inputOutputParity };
throw { fluenterror: HMSTATUS.inputOutputParity, quit: true };
}
else if( srcs.length === 2 ) {
dst = dst || []; dst.push( srcs.pop() );
}
else {
throw { fluenterror: HMSTATUS.inputOutputParity };
throw { fluenterror: HMSTATUS.inputOutputParity, quit: true };
}
}
if(srcs && dst && srcs.length && dst.length && srcs.length !== dst.length){
throw { fluenterror: HMSTATUS.inputOutputParity };
throw { fluenterror: HMSTATUS.inputOutputParity, quit: true };
}
// Load source resumes

View File

@ -41,7 +41,8 @@ Implementation of the 'create' verb for HackMyResume.
*/
function create( src, dst, opts ) {
if(!src || !src.length) throw {fluenterror: HMSTATUS.createNameMissing};
if( !src || !src.length )
throw { fluenterror: HMSTATUS.createNameMissing, quit: true };
_.each( src, function( t ) {
var safeFmt = opts.format.toUpperCase();

View File

@ -67,13 +67,12 @@ Implementation of the 'peek' verb for HackMyResume.
// safeLoadJSON can only return a READ error or a PARSE error
if( obj.ex ) {
if( obj.ex.operation === 'parse' )
this.err( HMSTATUS.parseError, obj.ex );
else {
var errCode = obj.ex.operation === 'parse' ? HMSTATUS.parseError : HMSTATUS.readError;
if( errCode === HMSTATUS.readError )
obj.ex.quiet = true;
this.err( HMSTATUS.readError, obj.ex );
}
}
this.setError( errCode, obj.ex );
this.err( errCode, obj.ex );
}
}, this);

View File

@ -38,7 +38,9 @@ Implementation of the 'validate' verb for HackMyResume.
*/
function validate( sources, unused, opts ) {
if( !sources || !sources.length ) { throw { fluenterror: 6 }; }
if( !sources || !sources.length )
throw { fluenterror: HMSTATUS.resumeNotFoundAlt, quit: true };
var isValid = true;
var validator = require('is-my-json-valid');
@ -61,6 +63,7 @@ Implementation of the 'validate' verb for HackMyResume.
// If there was an error reading the resume
if( src.fluenterror ) {
if( opts.assert ) throw src;
this.setError( src.fluenterror, src );
return ret;
}

View File

@ -78,8 +78,19 @@ Definition of the Verb class.
payload.sub = subEvent;
this.fire('status', payload);
return true;
},
/**
Associate error info with the invocation.
*/
setError: function( code, obj ) {
this.errorCode = code;
this.errorObj = obj;
}
});
}());