@@ -31,9 +31,7 @@ async function fetchTemplates() {
31
31
let response = await fetch ( URL ) ;
32
32
33
33
if ( ! response . ok ) {
34
- console . warn ( `Failed to fetch templates from ${ URL } (HTTP ${ response . status } )` ) ;
35
-
36
- return [ ] ;
34
+ throw new Error ( `Failed to fetch templates from ${ URL } (HTTP ${ response . status } )` ) ;
37
35
}
38
36
39
37
/** @type {TemplatesByIdMetadata } */
@@ -49,7 +47,15 @@ async function fetchTemplates() {
49
47
}
50
48
}
51
49
52
- return ( await Promise . all ( tasks ) ) . filter ( template => template !== null ) ;
50
+ // Collect all results to display all errors at once
51
+ const results = await Promise . allSettled ( tasks ) ;
52
+ const failed = results . filter ( result => result . status === 'rejected' ) ;
53
+
54
+ if ( failed . length > 0 ) {
55
+ throw new Error ( `Failed to fetch some templates:\n${ failed . map ( result => result . reason . message ) . join ( '\n' ) } ` ) ;
56
+ }
57
+
58
+ return results . filter ( r => r . status === 'fulfilled' ) . map ( r => r . value ) ;
53
59
}
54
60
55
61
async function fetchTemplate ( templateMetadata , id ) {
@@ -58,9 +64,7 @@ async function fetchTemplate(templateMetadata, id) {
58
64
const response = await fetch ( ref ) ;
59
65
60
66
if ( ! response . ok ) {
61
- console . warn ( `Failed to fetch template ${ id } version ${ templateMetadata . version } from ${ ref } (HTTP ${ response . status } )` ) ;
62
-
63
- return null ;
67
+ throw new Error ( `Failed to fetch template ${ id } version ${ templateMetadata . version } from ${ ref } (HTTP ${ response . status } )` ) ;
64
68
}
65
69
66
70
try {
@@ -71,8 +75,6 @@ async function fetchTemplate(templateMetadata, id) {
71
75
72
76
return templateJson ;
73
77
} catch ( error ) {
74
- console . warn ( `Failed to parse template ${ id } version ${ templateMetadata . version } fetched from ${ ref } ` , error ) ;
75
-
76
- return null ;
78
+ throw new Error ( `Failed to parse template ${ id } version ${ templateMetadata . version } fetched from ${ ref } (error: ${ error . message } )` ) ;
77
79
}
78
80
}
0 commit comments