Skip to content

Commit cecc464

Browse files
Add logging for failed MQTT message handling
Signed-off-by: Kate Goldenring <[email protected]>
1 parent fa32e53 commit cecc464

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ spin-expressions = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
1616
spin-trigger = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
1717
spin-telemetry = { git = "https://github.com/fermyon/spin", tag = "v2.6.0" }
1818
tokio = { version = "1.37", features = ["full"] }
19+
tracing = { version = "0.1", features = ["log"] }
1920
paho-mqtt = { version = "0.12.3", features = [
2021
"vendored-ssl",
2122
] }

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ fn main() {
77
// Required for OpenSSL with musl
88
println!("cargo:rustc-link-arg=-lc");
99
}
10-
}
10+
}

src/lib.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,16 @@ impl MqttTrigger {
205205
match rx.recv().await {
206206
Ok(Some(msg)) => {
207207
// Handle the received message
208-
self.handle_mqtt_event(
209-
&component_id,
210-
msg.payload().to_vec(),
211-
msg.topic().to_owned(),
212-
)
213-
.await?;
208+
if let Err(e) = self
209+
.handle_mqtt_event(
210+
&component_id,
211+
msg.payload().to_vec(),
212+
msg.topic().to_owned(),
213+
)
214+
.await
215+
{
216+
tracing::error!("Error handling MQTT message: {:?}", e);
217+
}
214218
}
215219
Ok(None) => {
216220
// Todo: Figure out what this case is

0 commit comments

Comments
 (0)