Skip to content

Commit

Permalink
replace all console.error() with proper "throw Error" returns to return
Browse files Browse the repository at this point in the history
any failure to node-ical users without bugging the console ourself.
This closes #72
  • Loading branch information
jens-maus committed Dec 31, 2020
1 parent 981ab4f commit 7cdb3fb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ical.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ const exdateParameter = function (name) {
if (typeof exdate[name].toISOString === 'function') {
curr[name][exdate[name].toISOString().slice(0, 10)] = exdate[name];
} else {
console.error('No toISOString function in exdate[name]', exdate[name]);
throw new TypeError('No toISOString function in exdate[name]', exdate[name]);
}
}
});
Expand Down Expand Up @@ -411,7 +411,7 @@ module.exports = {
if (typeof curr.recurrenceid.toISOString === 'function') {
par[curr.uid].recurrences[curr.recurrenceid.toISOString().slice(0, 10)] = recurrenceObject;
} else {
console.error('No toISOString function in curr.recurrenceid', curr.recurrenceid);
throw new TypeError('No toISOString function in curr.recurrenceid', curr.recurrenceid);
}
}

Expand Down Expand Up @@ -468,17 +468,18 @@ module.exports = {
rule += `;DTSTART=${curr.start.toISOString().replace(/[-:]/g, '')}`;
rule = rule.replace(/\.\d{3}/, '');
} catch (error) {
console.error('ERROR when trying to convert to ISOString', error);
throw new Error('ERROR when trying to convert to ISOString', error);
}
} else {
console.error('No toISOString function in curr.start', curr.start);
throw new Error('No toISOString function in curr.start', curr.start);
}
}

// Make sure to catch error from rrule.fromString()
try {
curr.rrule = rrule.fromString(rule);
} catch {
} catch (error) {
throw error;
}
}
}
Expand Down

0 comments on commit 7cdb3fb

Please sign in to comment.