mirror of
				https://github.com/JuanCanham/HackMyResume.git
				synced 2025-11-04 06:47:27 +00:00 
			
		
		
		
	Add baseline support for -d or --debug flag.
For now, -d just force-emits the stack when there is one. In the future, it can trigger more detailed logging info.
This commit is contained in:
		@@ -3,7 +3,7 @@ Error-handling routines for HackMyResume.
 | 
			
		||||
@module error-handler.js
 | 
			
		||||
@license MIT. See LICENSE.md for details.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
// TODO: Logging library
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
(function() {
 | 
			
		||||
@@ -26,7 +26,9 @@ Error-handling routines for HackMyResume.
 | 
			
		||||
  */
 | 
			
		||||
  var ErrorHandler = module.exports = {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    init: function( debug ) {
 | 
			
		||||
      this.debug = debug;
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    err: function( ex, shouldExit ) {
 | 
			
		||||
 | 
			
		||||
@@ -62,8 +64,10 @@ Error-handling routines for HackMyResume.
 | 
			
		||||
        log( msg.toString() ) :
 | 
			
		||||
        log( chalk.red.bold('ERROR: ' + msg.toString()) );
 | 
			
		||||
 | 
			
		||||
      // Usually emit the stack
 | 
			
		||||
      ( showStack && ex.code !== 'ENOENT' ) && log( chalk.gray(ex.stack) );
 | 
			
		||||
      // Selectively show the stack trace
 | 
			
		||||
      if( (ex.stack || (ex.inner && ex.inner.stack)) &&
 | 
			
		||||
         ((showStack && ex.code !== 'ENOENT' ) || (this.debug) ))
 | 
			
		||||
        log( chalk.red( ex.stack || ex.stack.inner ) );
 | 
			
		||||
 | 
			
		||||
      // Let the error code be the process's return code.
 | 
			
		||||
      ( shouldExit || ex.shouldExit ) && process.exit( exitCode );
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user