Skip to content

Commit 46a0a5c

Browse files
committed
Indicate which mod causes integration error when possible
1 parent 5110351 commit 46a0a5c

File tree

3 files changed

+269
-55
lines changed

3 files changed

+269
-55
lines changed

src/gui/message.rs

+49-13
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use tokio::{
1515
};
1616
use tracing::{error, info};
1717

18+
use crate::integrate::{IntegrationErr, IntegrationErrKind};
1819
use crate::mod_lints::{LintId, LintReport};
1920
use crate::state::{ModData_v0_1_0 as ModData, ModOrGroup};
2021
use crate::{
@@ -174,7 +175,7 @@ impl ResolveMods {
174175
#[derive(Debug)]
175176
pub struct Integrate {
176177
rid: RequestID,
177-
result: Result<()>,
178+
result: Result<(), IntegrationErr>,
178179
}
179180

180181
impl Integrate {
@@ -207,15 +208,34 @@ impl Integrate {
207208
app.last_action_status =
208209
LastActionStatus::Success("Hook DLL and mod bundle installed.".to_string());
209210
}
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());
216233
}
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+
};
219239
app.last_action_status = LastActionStatus::Failure(e.to_string());
220240
}
221241
},
@@ -360,10 +380,16 @@ async fn integrate_async(
360380
fsd_pak: PathBuf,
361381
rid: RequestID,
362382
message_tx: Sender<Message>,
363-
) -> Result<()> {
383+
) -> Result<(), IntegrationErr> {
364384
let update = false;
365385

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+
})?;
367393

368394
let to_integrate = mod_specs
369395
.iter()
@@ -396,12 +422,22 @@ async fn integrate_async(
396422
}
397423
});
398424

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+
})?;
400432

401433
tokio::task::spawn_blocking(|| {
402434
crate::integrate::integrate(fsd_pak, to_integrate.into_iter().zip(paths).collect())
403435
})
404-
.await??;
436+
.await
437+
.map_err(|e| IntegrationErr {
438+
mod_ctxt: None,
439+
kind: IntegrationErrKind::Generic(e.into()),
440+
})??;
405441

406442
Ok(())
407443
}

0 commit comments

Comments
 (0)