@@ -15,6 +15,7 @@ use tokio::{
15
15
} ;
16
16
use tracing:: { error, info} ;
17
17
18
+ use crate :: integrate:: { IntegrationErr , IntegrationErrKind } ;
18
19
use crate :: mod_lints:: { LintId , LintReport } ;
19
20
use crate :: state:: { ModData_v0_1_0 as ModData , ModOrGroup } ;
20
21
use crate :: {
@@ -174,7 +175,7 @@ impl ResolveMods {
174
175
#[ derive( Debug ) ]
175
176
pub struct Integrate {
176
177
rid : RequestID ,
177
- result : Result < ( ) > ,
178
+ result : Result < ( ) , IntegrationErr > ,
178
179
}
179
180
180
181
impl Integrate {
@@ -207,15 +208,34 @@ impl Integrate {
207
208
app. last_action_status =
208
209
LastActionStatus :: Success ( "Hook DLL and mod bundle installed." . to_string ( ) ) ;
209
210
}
210
- Err ( e) => match e. downcast :: < IntegrationError > ( ) {
211
- Ok ( IntegrationError :: NoProvider { url : _, factory } ) => {
212
- app. window_provider_parameters =
213
- Some ( WindowProviderParameters :: new ( factory, & app. state ) ) ;
214
- app. last_action_status =
215
- LastActionStatus :: Failure ( "No provider." . to_string ( ) ) ;
211
+ Err ( IntegrationErr { mod_ctxt, kind } ) => match kind {
212
+ IntegrationErrKind :: Generic ( e) => match e. downcast :: < IntegrationError > ( ) {
213
+ Ok ( IntegrationError :: NoProvider { url : _, factory } ) => {
214
+ app. window_provider_parameters =
215
+ Some ( WindowProviderParameters :: new ( factory, & app. state ) ) ;
216
+ app. last_action_status =
217
+ LastActionStatus :: Failure ( "No provider." . to_string ( ) ) ;
218
+ }
219
+ Err ( e) => {
220
+ match mod_ctxt {
221
+ Some ( mod_ctxt) => error ! ( "error encountered during integration while working with mod `{:?}`\n {:#?}\n {}" , mod_ctxt, e, e. backtrace( ) ) ,
222
+ None => error ! ( "{:#?}\n {}" , e, e. backtrace( ) ) ,
223
+ } ;
224
+ app. last_action_status = LastActionStatus :: Failure ( e. to_string ( ) ) ;
225
+ }
226
+ } ,
227
+ IntegrationErrKind :: Repak ( e) => {
228
+ match mod_ctxt {
229
+ Some ( mod_ctxt) => error ! ( "`repak` error encountered during integration while working with mod `{:?}`\n {:#?}" , mod_ctxt, e) ,
230
+ None => error ! ( "`repak` error encountered during integration: {:#?}" , e) ,
231
+ } ;
232
+ app. last_action_status = LastActionStatus :: Failure ( e. to_string ( ) ) ;
216
233
}
217
- Err ( e) => {
218
- error ! ( "{:#?}\n {}" , e, e. backtrace( ) ) ;
234
+ IntegrationErrKind :: UnrealAsset ( e) => {
235
+ match mod_ctxt {
236
+ Some ( mod_ctxt) => error ! ( "`unreal_asset` error encountered during integration while working with mod `{:?}`\n {:#?}" , mod_ctxt, e) ,
237
+ None => error ! ( "`unreal_asset` error encountered during integration: {:#?}" , e) ,
238
+ } ;
219
239
app. last_action_status = LastActionStatus :: Failure ( e. to_string ( ) ) ;
220
240
}
221
241
} ,
@@ -360,10 +380,16 @@ async fn integrate_async(
360
380
fsd_pak : PathBuf ,
361
381
rid : RequestID ,
362
382
message_tx : Sender < Message > ,
363
- ) -> Result < ( ) > {
383
+ ) -> Result < ( ) , IntegrationErr > {
364
384
let update = false ;
365
385
366
- let mods = store. resolve_mods ( & mod_specs, update) . await ?;
386
+ let mods = store
387
+ . resolve_mods ( & mod_specs, update)
388
+ . await
389
+ . map_err ( |e| IntegrationErr {
390
+ mod_ctxt : None ,
391
+ kind : IntegrationErrKind :: Generic ( e) ,
392
+ } ) ?;
367
393
368
394
let to_integrate = mod_specs
369
395
. iter ( )
@@ -396,12 +422,22 @@ async fn integrate_async(
396
422
}
397
423
} ) ;
398
424
399
- let paths = store. fetch_mods ( & urls, update, Some ( tx) ) . await ?;
425
+ let paths = store
426
+ . fetch_mods ( & urls, update, Some ( tx) )
427
+ . await
428
+ . map_err ( |e| IntegrationErr {
429
+ mod_ctxt : None ,
430
+ kind : IntegrationErrKind :: Generic ( e) ,
431
+ } ) ?;
400
432
401
433
tokio:: task:: spawn_blocking ( || {
402
434
crate :: integrate:: integrate ( fsd_pak, to_integrate. into_iter ( ) . zip ( paths) . collect ( ) )
403
435
} )
404
- . await ??;
436
+ . await
437
+ . map_err ( |e| IntegrationErr {
438
+ mod_ctxt : None ,
439
+ kind : IntegrationErrKind :: Generic ( e. into ( ) ) ,
440
+ } ) ??;
405
441
406
442
Ok ( ( ) )
407
443
}
0 commit comments