mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 08:20:11 +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')
|
||||
, FCMD = require('../hackmyapi')
|
||||
, PATH = require('path')
|
||||
, WRAP = require('word-wrap')
|
||||
, chalk = require('chalk');
|
||||
|
||||
|
||||
@ -78,68 +79,76 @@ Error-handling routines for HackMyResume.
|
||||
switch( ex.fluenterror ) {
|
||||
|
||||
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;
|
||||
|
||||
case HACKMYSTATUS.copyCSS:
|
||||
msg = "Couldn't copy CSS file to destination folder";
|
||||
msg = formatWarning("Couldn't copy CSS file to destination folder.");
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.resumeNotFound:
|
||||
msg = chalk.yellow('Please ') + chalk.yellow.bold('feed me a resume') +
|
||||
chalk.yellow(' in FRESH or JSON Resume format.');
|
||||
msg = formatWarning('Please ' + chalk.bold('feed me a resume') +
|
||||
' in FRESH or JSON Resume format.');
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.missingCommand:
|
||||
msg = chalk.yellow("Please ") + chalk.yellow.bold("give me a command") +
|
||||
chalk.yellow(" (");
|
||||
msg = formatWarning("Please " +chalk.bold("give me a command") + " (");
|
||||
|
||||
msg += Object.keys( FCMD.verbs ).map( function(v, idx, ar) {
|
||||
return (idx === ar.length - 1 ? chalk.yellow('or ') : '') +
|
||||
chalk.yellow.bold(v.toUpperCase());
|
||||
}).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;
|
||||
|
||||
case HACKMYSTATUS.invalidCommand:
|
||||
msg = chalk.yellow('Invalid command: "') + chalk.yellow.bold(ex.attempted) + chalk.yellow('"');
|
||||
msg = formatWarning('Invalid command: "'+chalk.bold(ex.attempted)+'"');
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.resumeNotFoundAlt:
|
||||
msg = chalk.yellow('Please ') + chalk.yellow.bold('feed me a resume') +
|
||||
chalk.yellow(' in either FRESH or JSON Resume format.');
|
||||
msg = formatWarning('Please ' + chalk.bold('feed me a resume') +
|
||||
' in either FRESH or JSON Resume format.');
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.inputOutputParity:
|
||||
msg = chalk.yellow('Please ') + chalk.yellow.bold('specify an output file name') +
|
||||
chalk.yellow(' for every input file you wish to convert.');
|
||||
msg = formatWarning('Please ' +
|
||||
chalk.bold('specify an output file name') +
|
||||
' for every input file you wish to convert.');
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.createNameMissing:
|
||||
msg = chalk.yellow('Please ') + chalk.yellow.bold('specify the filename of the resume') +
|
||||
chalk.yellow(' to create.');
|
||||
msg = formatWarning('Please ' +
|
||||
chalk.bold('specify the filename of the resume') + ' to create.');
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.pdfGeneration:
|
||||
msg = chalk.red.bold('ERROR: PDF generation failed. ') + chalk.red('Make sure wkhtmltopdf is ' +
|
||||
'installed and accessible from your path.');
|
||||
msg = formatError(chalk.bold('ERROR: PDF generation failed. ') +
|
||||
'Make sure wkhtmltopdf is installed and accessible from your path.');
|
||||
if( ex.inner ) msg += chalk.red('\n' + ex.inner);
|
||||
withStack = true;
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
case HACKMYSTATUS.invalidFormat:
|
||||
ex.data.forEach(function(d){
|
||||
msg += chalk.red.bold('The ' + ex.theme.name + " theme doesn't support the " + d.format + " format.\n");
|
||||
ex.data.forEach(function(d){ msg +=
|
||||
formatWarning('The ' + chalk.bold(ex.theme.name.toUpperCase()) +
|
||||
" theme doesn't support the " + chalk.bold(d.format.toUpperCase()) +
|
||||
" format.\n");
|
||||
});
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
@ -153,5 +162,9 @@ Error-handling routines for HackMyResume.
|
||||
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