@@ -74,20 +74,26 @@ export class JsonSchemaUnifier {
74
74
75
75
private async loadSchema ( schemaPath : string ) {
76
76
if ( this . schemata [ schemaPath ] . schema ) return this . schemata [ schemaPath ] . schema ;
77
- this . log ( "Loading" , schemaPath ) ;
78
- const parts = schemaPath . split ( "#" ) ;
79
- const filePath = parts [ 0 ] ;
80
- let schema : any ;
81
- if ( parts . length > 1 ) {
82
- schema = await this . loadSchema ( filePath ) ;
83
- schema = parts [ 1 ] . split ( "/" ) . filter ( p => p ) . reduce ( ( schema , key ) => schema [ key ] , schema ) ;
77
+ try {
78
+ this . log ( "Loading" , schemaPath ) ;
79
+ const parts = schemaPath . split ( "#" ) ;
80
+ const filePath = parts [ 0 ] ;
81
+ let schema : any ;
82
+ if ( parts . length > 1 ) {
83
+ schema = await this . loadSchema ( filePath ) ;
84
+ schema = parts [ 1 ] . split ( "/" ) . filter ( p => p ) . reduce ( ( schema , key ) => schema [ key ] , schema ) ;
85
+ }
86
+ else {
87
+ const schemaContent = await readFile ( filePath , 'utf-8' ) ;
88
+ schema = filePath . endsWith ( ".json" ) ? JSON . parse ( schemaContent ) : YAML . parse ( schemaContent ) ;
89
+ this . replaceRefs ( filePath , schema ) ;
90
+ }
91
+ this . schemata [ schemaPath ] . schema = schema ;
84
92
}
85
- else {
86
- const schemaContent = await readFile ( filePath , 'utf-8' ) ;
87
- schema = filePath . endsWith ( ".json" ) ? JSON . parse ( schemaContent ) : YAML . parse ( schemaContent ) ;
88
- this . replaceRefs ( filePath , schema ) ;
93
+ catch ( error ) {
94
+ console . error ( "Error occurred while loading schema" , schemaPath , error ) ;
95
+ throw error ;
89
96
}
90
- this . schemata [ schemaPath ] . schema = schema ;
91
97
}
92
98
93
99
private newPath ( path : string ) : string {
0 commit comments