You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If date falls outside of min/max dates, throw an error throwIfDateIsOutOfRange
Message: "Date is out of range: It should be between x & x..."
Steps to reproduce
Pass bad date as an input to getDates or getMatrix.
constCalendarDates=require("calendar-dates");constcalendarDates=newCalendarDates();constlog=console.log;// const may2018 = new Date(0,0,2);constmay2018=1;mainAsync=async()=>{constmayDates=awaitcalendarDates.getDates(may2018);constmayMatrix=awaitcalendarDates.getMatrix(may2018);// throw new Error('random error');log(`May, 2018 Dates`,mayDates);log(`May, 2018 Matrix`,mayMatrix);};mainAsync();
node v9.7.1 linux/amd64
(node:103) UnhandledPromiseRejectionWarning: TypeError: t.getMonth is not a function
at getPreviousDates (/home/runner/node_modules/calendar-dates/dist/calendardates.cjs.js:1:1243)
at /home/runner/node_modules/calendar-dates/dist/calendardates.cjs.js:1:663
at new Promise (<anonymous>)
at getDatesWithMetadata (/home/runner/node_modules/calendar-dates/dist/calendardates.cjs.js:1:628)
at /home/runner/node_modules/calendar-dates/dist/calendardates.cjs.js:1:2193
at new Promise (<anonymous>)
at t.value (/home/runner/node_modules/calendar-dates/dist/calendardates.cjs.js:1:2160)
at mainAsync (evalmachine.<anonymous>:9:40)
at evalmachine.<anonymous>:15:1
at Script.runInContext (vm.js:74:29)
(node:103) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async functionwithout a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:103) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
=> Promise { <pending> }
To Do
getDates
getMatrix
throwIfDateIsInvalid
throwIfDateIsOutOfRange
Steps to reproduce
Pass bad date as an input to
getDates
orgetMatrix
.Try it here.
https://repl.it/@dance2die/calendar-date-edge-cases
Expected behavior
Report a better error message that the exception is thrown due to invalid date input.
The text was updated successfully, but these errors were encountered: