Code coverage report for master/lib/jsdoc/util/error.js

Statements: 100% (6 / 6)      Branches: 100% (6 / 6)      Functions: 100% (1 / 1)      Lines: 100% (6 / 6)      Ignored: none     

All files » master/lib/jsdoc/util/ » error.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                                              1 3 3     3 1     3    
/**
 * Helper functions for handling errors.
 *
 * @deprecated As of JSDoc 3.3.0. This module may be removed in a future release. Use the module
 * {@link module:jsdoc/util/logger} to log warnings and errors.
 * @module jsdoc/util/error
 */
'use strict';
 
/**
 * Log an exception as an error.
 *
 * Prior to JSDoc 3.3.0, this method would either log the exception (if lenient mode was enabled) or
 * re-throw the exception (default).
 *
 * In JSDoc 3.3.0 and later, lenient mode has been replaced with strict mode, which is disabled by
 * default. If strict mode is enabled, calling the `handle` method causes JSDoc to exit immediately,
 * just as if the exception had been re-thrown.
 *
 * @deprecated As of JSDoc 3.3.0. This module may be removed in a future release.
 * @param {Error} e - The exception to log.
 * @memberof module:jsdoc/util/error
 */
exports.handle = function(e) {
    var logger = require('jsdoc/util/logger');
    var msg = e ? ( e.message || JSON.stringify(e) ) : '';
 
    // include the error type if it's an Error object
    if (e instanceof Error) {
        msg = e.name + ': ' + msg;
    }
 
    logger.error(msg);
};