Skip to content

Commit 02440e7

Browse files
committed
fix: use Unknown for addon tag if config can't be read
1 parent 06825a2 commit 02440e7

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/wasm/src/config.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ pub struct Config {
2121

2222
impl Config {
2323
/// Try to get the config
24-
pub fn get_config() -> Result<Self> {
25-
let file = File::open(ADDON_CONFIG_FILE)?;
26-
27-
Ok(serde_json::from_reader(file)?)
24+
pub fn get_config() -> Option<Self> {
25+
if let Ok(file) = File::open(ADDON_CONFIG_FILE) {
26+
serde_json::from_reader(file).ok()
27+
} else {
28+
None
29+
}
2830
}
2931
}

src/wasm/src/sentry_gauge.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,14 @@ where
255255
..Default::default()
256256
}));
257257

258-
if let Ok(config) = Config::get_config() {
259-
scope.set_tag(
260-
"addon",
261-
format!("{}/{}", config.addon.developer, config.addon.product),
262-
);
263-
}
258+
scope.set_tag(
259+
"addon",
260+
if let Some(config) = Config::get_config() {
261+
format!("{}/{}", config.addon.developer, config.addon.product)
262+
} else {
263+
"Unknown".into()
264+
},
265+
);
264266
});
265267

266268
// Drain any pending reports. We need to structure it like this as opposed to just a top level `let Ok(state) = ...`` due to the fact we should not be holding a MutexGuard across an await point

0 commit comments

Comments
 (0)