Changed processDate function to throw if it cannot complete conversion

This commit is contained in:
Alexander Cerutti
2021-10-11 21:23:30 +02:00
parent a052858950
commit a3c7851d92
2 changed files with 9 additions and 14 deletions

View File

@@ -698,15 +698,13 @@ export default class PKPass extends Bundle {
return;
}
const parsedDate = processDate("expirationDate", date);
if (!parsedDate) {
try {
this[propsSymbol]["expirationDate"] = processDate(date);
} catch (err) {
throw new TypeError(
`Cannot set expirationDate. Invalid date ${date}`,
);
}
this[propsSymbol]["expirationDate"] = parsedDate;
}
/**
@@ -789,15 +787,13 @@ export default class PKPass extends Bundle {
return;
}
const parsedDate = processDate("relevantDate", date);
if (!parsedDate) {
try {
this[propsSymbol]["relevantDate"] = processDate(date);
} catch (err) {
throw new TypeError(
`Cannot set relevantDate. Invalid date ${date}`,
);
}
this[propsSymbol]["relevantDate"] = parsedDate;
}
/**