mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Remove deprecated jsdoc/util/error module.
This commit is contained in:
parent
5fa9d1ac11
commit
ebe1ba1d36
@ -1,32 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* 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 = e => {
|
|
||||||
const logger = require('jsdoc/util/logger');
|
|
||||||
let 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);
|
|
||||||
};
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
describe('jsdoc/util/error', () => {
|
|
||||||
const error = require('jsdoc/util/error');
|
|
||||||
const handle = error.handle;
|
|
||||||
const logger = require('jsdoc/util/logger');
|
|
||||||
|
|
||||||
it('should exist', () => {
|
|
||||||
expect(error).toBeDefined();
|
|
||||||
expect(typeof error).toBe('object');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should export a "handle" function', () => {
|
|
||||||
expect(handle).toBeDefined();
|
|
||||||
expect(typeof handle).toBe('function');
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('handle', () => {
|
|
||||||
it('should not throw', () => {
|
|
||||||
expect(handle).not.toThrow();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should log messages with logger.error()', () => {
|
|
||||||
spyOn(logger, 'error');
|
|
||||||
handle('test');
|
|
||||||
|
|
||||||
expect(logger.error).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should use special formatting for Error instances', () => {
|
|
||||||
spyOn(logger, 'error');
|
|
||||||
handle( new Error('Oh no!') );
|
|
||||||
|
|
||||||
expect(logger.error).toHaveBeenCalledWith('Error: Oh no!');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Loading…
x
Reference in New Issue
Block a user