Skip to content

Commit f3ea439

Browse files
committed
Fail gracefully if it doesnt exist
1 parent 61f7e6f commit f3ea439

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

libdd-crashtracker/src/collector/unhandled_exception_handler.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ pub fn report_unhandled_exception(
1010
error_message: Option<&str>,
1111
stack: StackTrace,
1212
) -> anyhow::Result<()> {
13-
// if metadata or config is not set, then just return gracefully
14-
let metadata = crash_handler::get_metadata()
15-
.ok_or_else(|| anyhow::anyhow!("Crash tracker not initialized: no metadata available"))?;
16-
let config = crash_handler::get_config()
17-
.ok_or_else(|| anyhow::anyhow!("Crash tracker not initialized: no config available"))?;
13+
// If crash tracker has not been initialized, return
14+
let Some(metadata) = crash_handler::get_metadata() else {
15+
return Ok(());
16+
};
17+
let Some(config) = crash_handler::get_config() else {
18+
return Ok(());
19+
};
1820

1921
let mut builder = CrashInfoBuilder::new();
2022
builder.with_kind(ErrorKind::UnhandledException)?;

0 commit comments

Comments
 (0)