File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed
packages/db/src/impl/pouch Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -27,16 +27,29 @@ import CourseLookup from './courseLookupDB';
2727export class CoursesDB implements CoursesDBInterface {
2828 public async getCourseList ( ) : Promise < CourseConfig [ ] > {
2929 const crsList = await CourseLookup . allCourses ( ) ;
30-
31- return await Promise . all (
32- crsList . map ( ( c ) => {
33- return getCredentialledCourseConfig ( c . _id ) ;
30+ console . log ( `AllCourses: ${ crsList . map ( ( c ) => c . name ) } ` ) ;
31+
32+ const cfgs = await Promise . all (
33+ crsList . map ( async ( c ) => {
34+ try {
35+ const cfg = await getCredentialledCourseConfig ( c . _id ) ;
36+ console . log ( `Found cfg: ${ JSON . stringify ( cfg ) } ` ) ;
37+ return cfg ;
38+ } catch ( e ) {
39+ return undefined ;
40+ }
3441 } )
3542 ) ;
43+ return cfgs . filter ( ( c ) => ! ! c ) ;
3644 }
3745
3846 async getCourseConfig ( courseId : string ) : Promise < CourseConfig > {
39- return getCredentialledCourseConfig ( courseId ) ;
47+ const cfg = await getCredentialledCourseConfig ( courseId ) ;
48+ if ( cfg === undefined ) {
49+ throw new Error ( `Error fetching cfg for course ${ courseId } ` ) ;
50+ } else {
51+ return cfg ;
52+ }
4053 }
4154
4255 public async disambiguateCourse ( courseId : string , disambiguator : string ) : Promise < void > {
@@ -661,7 +674,7 @@ ${JSON.stringify(config)}
661674
662675 return await db . put < CourseConfig > ( {
663676 ...config ,
664- _rev : old . _rev ,
677+ _rev : ( old as any ) . _rev ,
665678 } ) ;
666679}
667680
You can’t perform that action at this time.
0 commit comments