@@ -124,58 +124,63 @@ export class ModrinthServer {
124
124
return dataURL ;
125
125
}
126
126
} catch ( error ) {
127
- if ( error instanceof ModrinthServerError && error . statusCode === 404 && iconUrl ) {
128
- // Handle external icon processing
129
- try {
130
- const response = await fetch ( iconUrl ) ;
131
- if ( ! response . ok ) throw new Error ( "Failed to fetch icon" ) ;
132
- const file = await response . blob ( ) ;
133
- const originalFile = new File ( [ file ] , "server-icon-original.png" , {
134
- type : "image/png" ,
135
- } ) ;
136
-
137
- if ( import . meta. client ) {
138
- const dataURL = await new Promise < string > ( ( resolve ) => {
139
- const canvas = document . createElement ( "canvas" ) ;
140
- const ctx = canvas . getContext ( "2d" ) ;
141
- const img = new Image ( ) ;
142
- img . onload = ( ) => {
143
- canvas . width = 64 ;
144
- canvas . height = 64 ;
145
- ctx ?. drawImage ( img , 0 , 0 , 64 , 64 ) ;
146
- canvas . toBlob ( async ( blob ) => {
147
- if ( blob ) {
148
- const scaledFile = new File ( [ blob ] , "server-icon.png" , { type : "image/png" } ) ;
149
- await useServersFetch ( `/create?path=/server-icon.png&type=file` , {
150
- method : "POST" ,
151
- contentType : "application/octet-stream" ,
152
- body : scaledFile ,
153
- override : auth ,
154
- } ) ;
155
- await useServersFetch ( `/create?path=/server-icon-original.png&type=file` , {
156
- method : "POST" ,
157
- contentType : "application/octet-stream" ,
158
- body : originalFile ,
159
- override : auth ,
160
- } ) ;
161
- }
162
- } , "image/png" ) ;
163
- const dataURL = canvas . toDataURL ( "image/png" ) ;
164
- sharedImage . value = dataURL ;
165
- resolve ( dataURL ) ;
166
- URL . revokeObjectURL ( img . src ) ;
167
- } ;
168
- img . src = URL . createObjectURL ( file ) ;
127
+ if ( error instanceof ModrinthServerError && error . statusCode === 404 ) {
128
+ if ( iconUrl ) {
129
+ try {
130
+ const response = await fetch ( iconUrl ) ;
131
+ if ( ! response . ok ) throw new Error ( "Failed to fetch icon" ) ;
132
+ const file = await response . blob ( ) ;
133
+ const originalFile = new File ( [ file ] , "server-icon-original.png" , {
134
+ type : "image/png" ,
169
135
} ) ;
170
- return dataURL ;
136
+
137
+ if ( import . meta. client ) {
138
+ const dataURL = await new Promise < string > ( ( resolve ) => {
139
+ const canvas = document . createElement ( "canvas" ) ;
140
+ const ctx = canvas . getContext ( "2d" ) ;
141
+ const img = new Image ( ) ;
142
+ img . onload = ( ) => {
143
+ canvas . width = 64 ;
144
+ canvas . height = 64 ;
145
+ ctx ?. drawImage ( img , 0 , 0 , 64 , 64 ) ;
146
+ canvas . toBlob ( async ( blob ) => {
147
+ if ( blob ) {
148
+ const scaledFile = new File ( [ blob ] , "server-icon.png" , {
149
+ type : "image/png" ,
150
+ } ) ;
151
+ await useServersFetch ( `/create?path=/server-icon.png&type=file` , {
152
+ method : "POST" ,
153
+ contentType : "application/octet-stream" ,
154
+ body : scaledFile ,
155
+ override : auth ,
156
+ } ) ;
157
+ await useServersFetch ( `/create?path=/server-icon-original.png&type=file` , {
158
+ method : "POST" ,
159
+ contentType : "application/octet-stream" ,
160
+ body : originalFile ,
161
+ override : auth ,
162
+ } ) ;
163
+ }
164
+ } , "image/png" ) ;
165
+ const dataURL = canvas . toDataURL ( "image/png" ) ;
166
+ sharedImage . value = dataURL ;
167
+ resolve ( dataURL ) ;
168
+ URL . revokeObjectURL ( img . src ) ;
169
+ } ;
170
+ img . src = URL . createObjectURL ( file ) ;
171
+ } ) ;
172
+ return dataURL ;
173
+ }
174
+ } catch ( externalError : any ) {
175
+ console . debug ( "Could not process external icon:" , externalError . message ) ;
171
176
}
172
- } catch ( error ) {
173
- console . error ( "Failed to process external icon:" , error ) ;
174
177
}
178
+ } else {
179
+ throw error ;
175
180
}
176
181
}
177
- } catch ( error ) {
178
- console . error ( "Failed to process server icon :", error ) ;
182
+ } catch ( error : any ) {
183
+ console . debug ( "Icon processing failed :", error . message ) ;
179
184
}
180
185
181
186
sharedImage . value = undefined ;
@@ -239,6 +244,18 @@ export class ModrinthServer {
239
244
break ;
240
245
}
241
246
} catch ( error ) {
247
+ if ( error instanceof ModrinthServerError ) {
248
+ if ( error . statusCode === 404 && [ "fs" , "content" ] . includes ( module ) ) {
249
+ console . debug ( `Optional ${ module } resource not found:` , error . message ) ;
250
+ continue ;
251
+ }
252
+
253
+ if ( error . statusCode === 503 ) {
254
+ console . debug ( `Temporary ${ module } unavailable:` , error . message ) ;
255
+ continue ;
256
+ }
257
+ }
258
+
242
259
this . errors [ module ] = {
243
260
error :
244
261
error instanceof ModrinthServerError
0 commit comments