fix: 🐛 Return a empty array if backend returns a specific error
If this error it returned from backend a child has no schedule. Better to return an empty array than spamming the log with errors.
This commit is contained in:
parent
b88b460bd6
commit
1e944adf24
|
@ -20,5 +20,21 @@ export const scheduleItem = ({
|
|||
oneDayEvent: isSameDay,
|
||||
})
|
||||
|
||||
export const schedule = (data: any): ScheduleItem[] =>
|
||||
etjanst(data).map(scheduleItem)
|
||||
export const schedule = (data: any): ScheduleItem[] => {
|
||||
try{
|
||||
const scheduleData = etjanst(data)
|
||||
const mapped = scheduleData.map(scheduleItem)
|
||||
return mapped
|
||||
}
|
||||
catch(e){
|
||||
if (e instanceof Error) {
|
||||
// If this happens the child has no schedule
|
||||
// It is the same on the official web
|
||||
// Instead of retrying and spamming errors - lets return en empty array
|
||||
if(e.message === 'A task was canceled.'){
|
||||
return new Array<ScheduleItem>()
|
||||
}
|
||||
}
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue