mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-05 09:56:22 +00:00
Improve error vs. warning formatting.
Errors = red. Warnings = yellow.
This commit is contained in:
parent
29c53af843
commit
f3dcbd9081
@ -15,6 +15,7 @@ Error-handling routines for HackMyResume.
|
|||||||
, FS = require('fs')
|
, FS = require('fs')
|
||||||
, FCMD = require('../hackmyapi')
|
, FCMD = require('../hackmyapi')
|
||||||
, PATH = require('path')
|
, PATH = require('path')
|
||||||
|
, WRAP = require('word-wrap')
|
||||||
, chalk = require('chalk');
|
, chalk = require('chalk');
|
||||||
|
|
||||||
|
|
||||||
@ -78,68 +79,76 @@ Error-handling routines for HackMyResume.
|
|||||||
switch( ex.fluenterror ) {
|
switch( ex.fluenterror ) {
|
||||||
|
|
||||||
case HACKMYSTATUS.themeNotFound:
|
case HACKMYSTATUS.themeNotFound:
|
||||||
msg = "The specified theme couldn't be found: " + ex.data;
|
msg = formatWarning(
|
||||||
|
chalk.bold("Couldn't find the '" + ex.data + "' theme."),
|
||||||
|
" Please specify the name of a preinstalled FRESH theme " +
|
||||||
|
"or the path to a locally installed FRESH or JSON Resume theme.");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HACKMYSTATUS.copyCSS:
|
case HACKMYSTATUS.copyCSS:
|
||||||
msg = "Couldn't copy CSS file to destination folder";
|
msg = formatWarning("Couldn't copy CSS file to destination folder.");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HACKMYSTATUS.resumeNotFound:
|
case HACKMYSTATUS.resumeNotFound:
|
||||||
msg = chalk.yellow('Please ') + chalk.yellow.bold('feed me a resume') +
|
msg = formatWarning('Please ' + chalk.bold('feed me a resume') +
|
||||||
chalk.yellow(' in FRESH or JSON Resume format.');
|
' in FRESH or JSON Resume format.');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HACKMYSTATUS.missingCommand:
|
case HACKMYSTATUS.missingCommand:
|
||||||
msg = chalk.yellow("Please ") + chalk.yellow.bold("give me a command") +
|
msg = formatWarning("Please " +chalk.bold("give me a command") + " (");
|
||||||
chalk.yellow(" (");
|
|
||||||
|
|
||||||
msg += Object.keys( FCMD.verbs ).map( function(v, idx, ar) {
|
msg += Object.keys( FCMD.verbs ).map( function(v, idx, ar) {
|
||||||
return (idx === ar.length - 1 ? chalk.yellow('or ') : '') +
|
return (idx === ar.length - 1 ? chalk.yellow('or ') : '') +
|
||||||
chalk.yellow.bold(v.toUpperCase());
|
chalk.yellow.bold(v.toUpperCase());
|
||||||
}).join( chalk.yellow(', ')) + chalk.yellow(").\n\n");
|
}).join( chalk.yellow(', ')) + chalk.yellow(").\n\n");
|
||||||
|
|
||||||
msg += chalk.gray(FS.readFileSync( PATH.resolve(__dirname, '../use.txt'), 'utf8' ));
|
msg += chalk.gray(FS.readFileSync(
|
||||||
|
PATH.resolve(__dirname, '../use.txt'), 'utf8' ));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HACKMYSTATUS.invalidCommand:
|
case HACKMYSTATUS.invalidCommand:
|
||||||
msg = chalk.yellow('Invalid command: "') + chalk.yellow.bold(ex.attempted) + chalk.yellow('"');
|
msg = formatWarning('Invalid command: "'+chalk.bold(ex.attempted)+'"');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HACKMYSTATUS.resumeNotFoundAlt:
|
case HACKMYSTATUS.resumeNotFoundAlt:
|
||||||
msg = chalk.yellow('Please ') + chalk.yellow.bold('feed me a resume') +
|
msg = formatWarning('Please ' + chalk.bold('feed me a resume') +
|
||||||
chalk.yellow(' in either FRESH or JSON Resume format.');
|
' in either FRESH or JSON Resume format.');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HACKMYSTATUS.inputOutputParity:
|
case HACKMYSTATUS.inputOutputParity:
|
||||||
msg = chalk.yellow('Please ') + chalk.yellow.bold('specify an output file name') +
|
msg = formatWarning('Please ' +
|
||||||
chalk.yellow(' for every input file you wish to convert.');
|
chalk.bold('specify an output file name') +
|
||||||
|
' for every input file you wish to convert.');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HACKMYSTATUS.createNameMissing:
|
case HACKMYSTATUS.createNameMissing:
|
||||||
msg = chalk.yellow('Please ') + chalk.yellow.bold('specify the filename of the resume') +
|
msg = formatWarning('Please ' +
|
||||||
chalk.yellow(' to create.');
|
chalk.bold('specify the filename of the resume') + ' to create.');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HACKMYSTATUS.pdfGeneration:
|
case HACKMYSTATUS.pdfGeneration:
|
||||||
msg = chalk.red.bold('ERROR: PDF generation failed. ') + chalk.red('Make sure wkhtmltopdf is ' +
|
msg = formatError(chalk.bold('ERROR: PDF generation failed. ') +
|
||||||
'installed and accessible from your path.');
|
'Make sure wkhtmltopdf is installed and accessible from your path.');
|
||||||
if( ex.inner ) msg += chalk.red('\n' + ex.inner);
|
if( ex.inner ) msg += chalk.red('\n' + ex.inner);
|
||||||
withStack = true;
|
withStack = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HACKMYSTATUS.invalid:
|
case HACKMYSTATUS.invalid:
|
||||||
msg = chalk.red.bold('ERROR: Validation failed and the --assert option was specified.');
|
msg = formatError('Validation failed and the --assert option was ' +
|
||||||
|
'specified.');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HACKMYSTATUS.invalidFormat:
|
case HACKMYSTATUS.invalidFormat:
|
||||||
ex.data.forEach(function(d){
|
ex.data.forEach(function(d){ msg +=
|
||||||
msg += chalk.red.bold('The ' + ex.theme.name + " theme doesn't support the " + d.format + " format.\n");
|
formatWarning('The ' + chalk.bold(ex.theme.name.toUpperCase()) +
|
||||||
|
" theme doesn't support the " + chalk.bold(d.format.toUpperCase()) +
|
||||||
|
" format.\n");
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HACKMYSTATUS.notOnPath:
|
case HACKMYSTATUS.notOnPath:
|
||||||
msg = formatError( ex.engine + " wasn't found on your system path or is inaccessible. PDF not generated." );
|
msg = formatError( ex.engine + " wasn't found on your system path or" +
|
||||||
|
" is inaccessible. PDF not generated." );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -153,5 +162,9 @@ Error-handling routines for HackMyResume.
|
|||||||
return chalk.red.bold( 'ERROR: ' + msg );
|
return chalk.red.bold( 'ERROR: ' + msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatWarning( brief, msg ) {
|
||||||
|
return chalk.yellow(brief) + chalk.yellow(msg || '');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
Loading…
Reference in New Issue
Block a user