@@ -19,13 +19,13 @@ function parseTemplateFile(filePath) {
19
19
return parse ( readFileSync ( filePath , "utf8" ) ) ;
20
20
} catch ( error ) {
21
21
if ( error . code === "ENOENT" ) {
22
- throw Error ( `Template file not found: ${ filePath } ` , error ) ;
22
+ throw new Error ( `Template file not found: ${ filePath } ` , { message : error } ) ;
23
23
} else if ( error . name === "YAMLException" ) {
24
- throw Error ( "Invalid YAML in template file" , error ) ;
24
+ throw new Error ( "Invalid YAML in template file" , { message : error } ) ;
25
25
} else if ( error . name === "SyntaxError" ) {
26
- throw Error ( "Invalid JSON in template file" , error ) ;
26
+ throw new Error ( "Invalid JSON in template file" , { message : error } ) ;
27
27
}
28
- throw Error ( "Error reading template file" , error ) ;
28
+ throw new Error ( "Error reading template file" , { message : error } ) ;
29
29
}
30
30
}
31
31
@@ -43,7 +43,7 @@ async function dereferenceTemplates(templateDescriptions) {
43
43
try {
44
44
return await dereference ( templateDescriptions ) ;
45
45
} catch ( error ) {
46
- throw Error ( "Failed to dereference template schemas" , error ) ;
46
+ throw new Error ( "Failed to dereference template schemas" , { message : error } ) ;
47
47
}
48
48
}
49
49
@@ -61,7 +61,7 @@ function validateTemplates(templateDescriptions) {
61
61
for ( const templateName in templateDescriptions . templates ) {
62
62
const template = { [ templateName ] : templateDescriptions . templates [ templateName ] } ;
63
63
if ( ! validateTemplate ( template ) ) {
64
- throw Error ( "Template is invalid" , { message : JSON . stringify ( validateTemplate . errors ) } ) ;
64
+ throw new Error ( "Template is invalid" , { message : JSON . stringify ( validateTemplate . errors ) } ) ;
65
65
}
66
66
}
67
67
0 commit comments