Skip to content

Commit

Permalink
fix(subtitle): handle error rejected from fetchOnlinsSubs
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan Yifeng committed Apr 4, 2019
1 parent d55e085 commit 614f109
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/renderer/components/Subtitle/SubtitleManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { Subtitle as subtitleActions } from '@/store/actionTypes';
import SubtitleRenderer from './SubtitleRenderer.vue';
import SubtitleLoader from './SubtitleLoader';
import { localLanguageLoader } from './SubtitleLoader/utils';
import { LOCAL_SUBTITLE_REMOVED } from '../../../shared/notificationcodes';
import { LOCAL_SUBTITLE_REMOVED, REQUEST_TIMEOUT } from '../../../shared/notificationcodes';
export default {
name: 'subtitle-manager',
Expand Down Expand Up @@ -259,8 +259,19 @@ export default {
options: { language, data, id },
}))
.then(sub => this.addSubtitle(this.normalizeSubtitle(sub), videoSrc))
.catch(() => []);
const storedSubs = await Promise.all(storedSubIds.map(retrieveSub)).then(flatten);
.catch(err => (err instanceof Error ? new Error(err) : err));
const storedSubs = await Promise.all(storedSubIds.map(retrieveSub))
.then(subtitleResults => subtitleResults.filter((result) => {
if (result instanceof Error) {
this.addLog('error', {
message: 'Request Timeout .',
errcode: REQUEST_TIMEOUT,
});
return [];
}
return result;
}))
.then(flatten);
if (storedSubs.length) return storedSubs;
}
const hints = this.generateHints(videoSrc);
Expand Down

0 comments on commit 614f109

Please sign in to comment.