Skip to content

Commit

Permalink
Slight refactor of exception creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ichernev committed Dec 23, 2023
1 parent c475ab3 commit 04ea4a6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib/utils/create-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import isDate from './is-date';
/**
* Update an Error with the specified date, input and format.
*
* @param {*} error The error to update
* @param {*} message The error message
* @param {*} date The date
* @param {*} input The input
* @param {*} format The format
*/
function enhanceError(error, date, input, format) {
function makeError(message, date, input, format) {
var error = new Error(message);
error.date = date;
error.input = input;
error.format = format;
Expand All @@ -28,7 +29,7 @@ function enhanceError(error, date, input, format) {
stack: this.stack,
};
};
throw error;
return error;
}

/**
Expand All @@ -46,8 +47,7 @@ export default function createError(message, date, input, format) {
if (isDate(date) && date.toString() !== 'Invalid Date') {
return;
}
var error = new Error(message);
enhanceError(error, date, input, format);
throw makeError(message, date, input, format);
}

// Specify whether to disable throwing errors, ths default value is `true`
Expand Down

0 comments on commit 04ea4a6

Please sign in to comment.