Skip to content

Commit aac32b4

Browse files
committed
Validate list of captures in YMD selector
Throw relevant error when returning only status>=400 captures which cannot be used for comparison.
1 parent a82fd9f commit aac32b4

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/components/ymd-timestamp-header.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,14 @@ export default class YmdTimestampHeader extends React.Component {
212212

213213
return fetch(requestUrl)
214214
.then(jsonResponse)
215-
.then(data => data['items'])
215+
.then(data => {
216+
const items = data.items || [];
217+
const allErrors = items.length > 0 && items.every(item => item[1] >= 400);
218+
if (allErrors) {
219+
throw new Error(`Year ${year1} month ${month1} has no status=200 captures and cannot be used for comparison.`);
220+
}
221+
return items;
222+
})
216223
.then(data => data.map(item => [year1 + month1 + String(item[0]).padStart(8, '0'), item[2]]))
217224
.catch(error => { this._errorHandled(error.message); });
218225
};

0 commit comments

Comments
 (0)