function buildErrorObject(error) {
		var msg = error.message || 'Unknown error occurred';
		var errorName = errorTypes.includes(error.name) ? error.name : 'Error';
		var ErrConstructor = window[errorName] || Error;

		if (error.stack) {
			msg += '\n' + error.stack.replace(error.message, '');
		}
		return new ErrConstructor(msg);
	}
function buildErrorObject(error) {
		var msg = error.message || 'Unknown error occurred';
		var errorName = errorTypes.includes(error.name) ? error.name : 'Error';
		var ErrConstructor = window[errorName] || Error;

		if (error.stack) {
			msg += '\n' + error.stack.replace(error.message, '');
		}
		return new ErrConstructor(msg);
	}
function buildErrorObject ( error ) { var msg = error . message || 'Unknown error occurred' ; var errorName = errorTypes . includes ( error . name ) ? error . name : 'Error' ; var ErrConstructor = window [ errorName ] || Error ; if ( error . stack ) { msg += '\n' + error . stack . replace ( error . message , '' ) ; } return new ErrConstructor ( msg ) ; }
Convert a javascript Error into something that can be stringified
@param  {Error} error  Any type of error
@return {Object}       Processable object
Convert a javascript Error into something that can be stringified
Build an error object