mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-10 07:47:07 +01:00
Capture.
This commit is contained in:
@ -10,7 +10,7 @@ Error-handling routines for HackMyResume.
|
||||
|
||||
|
||||
|
||||
var HACKMYSTATUS = require('../core/status-codes')
|
||||
var HMSTATUS = require('../core/status-codes')
|
||||
, PKG = require('../../package.json')
|
||||
, FS = require('fs')
|
||||
, FCMD = require('../hackmyapi')
|
||||
@ -31,15 +31,18 @@ Error-handling routines for HackMyResume.
|
||||
*/
|
||||
var ErrorHandler = module.exports = {
|
||||
|
||||
init: function( debug, assert ) {
|
||||
init: function( debug, assert, silent ) {
|
||||
this.debug = debug;
|
||||
this.assert = assert;
|
||||
this.silent = silent;
|
||||
this.msgs = require('./msg.js').errors;
|
||||
return this;
|
||||
},
|
||||
|
||||
err: function( ex, shouldExit ) {
|
||||
|
||||
var o = this.silent ? function() { } : _defaultLog;
|
||||
|
||||
if( !this.msgs ) {
|
||||
this.msgs = require('./msg.js').errors;
|
||||
}
|
||||
@ -91,9 +94,9 @@ Error-handling routines for HackMyResume.
|
||||
};
|
||||
|
||||
|
||||
var o = function() {
|
||||
function _defaultLog() {
|
||||
console.log.apply( console.log, arguments );
|
||||
};
|
||||
}
|
||||
|
||||
function assembleError( ex ) {
|
||||
|
||||
@ -101,20 +104,20 @@ Error-handling routines for HackMyResume.
|
||||
|
||||
switch( ex.fluenterror ) {
|
||||
|
||||
case HACKMYSTATUS.themeNotFound:
|
||||
case HMSTATUS.themeNotFound:
|
||||
msg = printf( M2C( this.msgs.themeNotFound.msg, 'yellow' ), ex.data);
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.copyCSS:
|
||||
case HMSTATUS.copyCSS:
|
||||
msg = M2C( this.msgs.copyCSS.msg, 'red' );
|
||||
quit = false;
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.resumeNotFound:
|
||||
case HMSTATUS.resumeNotFound:
|
||||
msg = M2C( this.msgs.resumeNotFound.msg, 'yellow' );
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.missingCommand:
|
||||
case HMSTATUS.missingCommand:
|
||||
msg = M2C( this.msgs.missingCommand.msg + " (", 'yellow');
|
||||
msg += Object.keys( FCMD.verbs ).map( function(v, idx, ar) {
|
||||
return (idx === ar.length - 1 ? chalk.yellow('or ') : '') +
|
||||
@ -125,53 +128,53 @@ Error-handling routines for HackMyResume.
|
||||
PATH.resolve(__dirname, '../cli/use.txt'), 'utf8' ));
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.invalidCommand:
|
||||
case HMSTATUS.invalidCommand:
|
||||
msg = printf( M2C( this.msgs.invalidCommand.msg, 'yellow'), ex.attempted );
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.resumeNotFoundAlt:
|
||||
case HMSTATUS.resumeNotFoundAlt:
|
||||
msg = M2C( this.msgs.resumeNotFoundAlt.msg, 'yellow' );
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.inputOutputParity:
|
||||
case HMSTATUS.inputOutputParity:
|
||||
msg = M2C( this.msgs.inputOutputParity.msg );
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.createNameMissing:
|
||||
case HMSTATUS.createNameMissing:
|
||||
msg = M2C( this.msgs.createNameMissing.msg );
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.pdfGeneration:
|
||||
case HMSTATUS.pdfGeneration:
|
||||
msg = M2C( this.msgs.pdfGeneration.msg, 'bold' );
|
||||
if( ex.inner ) msg += chalk.red('\n' + ex.inner);
|
||||
withStack = true; quit = false; warn = false;
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.invalid:
|
||||
case HMSTATUS.invalid:
|
||||
msg = M2C( this.msgs.invalid.msg, 'red' );
|
||||
warn = false;
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.invalidFormat:
|
||||
case HMSTATUS.invalidFormat:
|
||||
ex.data.forEach(function(d){
|
||||
msg += printf( M2C( this.msgs.invalidFormat.msg, 'bold' ),
|
||||
ex.theme.name.toUpperCase(), d.format.toUpperCase());
|
||||
}, this);
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.notOnPath:
|
||||
case HMSTATUS.notOnPath:
|
||||
msg = printf( M2C(this.msgs.notOnPath.msg, 'bold'), ex.engine);
|
||||
quit = false;
|
||||
warn = false;
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.readError:
|
||||
case HMSTATUS.readError:
|
||||
console.error( printf( M2C(this.msgs.readError.msg, 'red'), ex.file ) );
|
||||
msg = ex.inner.toString();
|
||||
warn = false;
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.parseError:
|
||||
case HMSTATUS.parseError:
|
||||
if( SyntaxErrorEx.is( ex.inner )) {
|
||||
var se = new SyntaxErrorEx( ex, ex.raw );
|
||||
msg = printf( M2C( this.msgs.parseError.msg, 'red' ),
|
||||
|
@ -131,10 +131,10 @@ Definition of the `main` function.
|
||||
/** Massage command-line args and setup Commander.js. */
|
||||
function initialize( ar ) {
|
||||
|
||||
logMsg( _title );
|
||||
|
||||
var o = initOptions( ar );
|
||||
|
||||
o.silent || logMsg( _title );
|
||||
|
||||
// Emit debug prelude if --debug was specified
|
||||
if( o.debug ) {
|
||||
_out.log(chalk.cyan('The -d or --debug switch was specified. DEBUG mode engaged.'));
|
||||
@ -213,8 +213,14 @@ Definition of the `main` function.
|
||||
return v === '-d' || v === '--debug';
|
||||
});
|
||||
|
||||
// Grab the --silent flag
|
||||
var isSilent = _.some( args, function(v) {
|
||||
return v === '-s' || v === '--silent';
|
||||
});
|
||||
|
||||
return {
|
||||
debug: isDebug,
|
||||
silent: isSilent,
|
||||
orgVerb: oVerb,
|
||||
verb: verb,
|
||||
json: oJSON,
|
||||
@ -229,7 +235,7 @@ Definition of the `main` function.
|
||||
|
||||
loadOptions.call( this, opts, this.parent.jsonArgs );
|
||||
var hand = require( './error' );
|
||||
hand.init( _opts.debug, _opts.assert );
|
||||
hand.init( _opts.debug, _opts.assert, _opts.silent );
|
||||
var v = new HMR.verbs[ this.name() ]();
|
||||
_out.init( _opts );
|
||||
v.on( 'hmr:status', function() { _out.do.apply( _out, arguments ); });
|
||||
@ -271,7 +277,7 @@ Definition of the `main` function.
|
||||
logMsg(chalk.cyan('OPTIONS:') + '\n');
|
||||
_.each(o, function(val, key) {
|
||||
logMsg(chalk.cyan(' %s') + chalk.cyan.bold(' %s'),
|
||||
PAD(key,17,null,PAD.RIGHT), val);
|
||||
PAD(key,22,null,PAD.RIGHT), val);
|
||||
});
|
||||
logMsg('');
|
||||
}
|
||||
|
@ -47,10 +47,12 @@ events:
|
||||
- Peeking at **%s**
|
||||
afterPeek:
|
||||
msg: "The specified key **%s** was not found in **%s**."
|
||||
afterInlineConvert:
|
||||
msg: Converting **%s** to **%s** format.
|
||||
errors:
|
||||
themeNotFound:
|
||||
msg: >
|
||||
Couldn't find the '%s' theme. Please specify the name of a preinstalled
|
||||
**Couldn't find the '%s' theme.** Please specify the name of a preinstalled
|
||||
FRESH theme or the path to a locally installed FRESH or JSON Resume theme.
|
||||
copyCSS:
|
||||
msg: Couldn't copy CSS file to destination folder.
|
||||
|
@ -100,7 +100,7 @@ Output routines for HackMyResume.
|
||||
this.msgs.beforeMerge.msg[1] ), a.i().file
|
||||
);
|
||||
}, this);
|
||||
L( M2C(msg, 'cyan') );
|
||||
L( M2C(msg, 'green') );
|
||||
break;
|
||||
|
||||
case HME.afterMerge:
|
||||
@ -148,7 +148,7 @@ Output routines for HackMyResume.
|
||||
break;
|
||||
|
||||
case HME.beforeAnalyze:
|
||||
L( M2C( this.msgs.beforeAnalyze.msg, 'cyan' ), evt.fmt, evt.file);
|
||||
L( M2C( this.msgs.beforeAnalyze.msg, 'green' ), evt.fmt, evt.file);
|
||||
break;
|
||||
|
||||
case HME.afterAnalyze:
|
||||
@ -169,6 +169,11 @@ Output routines for HackMyResume.
|
||||
);
|
||||
break;
|
||||
|
||||
case HME.afterInlineConvert:
|
||||
L( M2C( this.msgs.afterInlineConvert.msg, 'green'),
|
||||
evt.file, evt.fmt );
|
||||
break;
|
||||
|
||||
case HME.afterValidate:
|
||||
var style = evt.isValid ? 'green' : 'yellow';
|
||||
L(
|
||||
|
Reference in New Issue
Block a user