Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,12 @@ function assign(obj, props) {
* @param {Extensions} [props] - Props to set on the error
* @returns {Error & Extensions}
*/
function createError(err, code, props) {
function createError(err, code, props = {}) {
if (!err || typeof err === 'string') {
throw new TypeError('Please pass an Error to err-code');
}

if (!props) {
props = {};
}

if (typeof code === 'object') {
props = code;
code = '';
}

if (code) {
props.code = code;
}
typeof code === 'object' ? props = code : props.code = code;

try {
return assign(err, props);
Expand Down