mirror of
https://github.com/meshtastic/web.git
synced 2026-08-02 16:09:19 -04:00
fix: log removeDevice failures with structured error fields
Apply reviewer feedback from PR #1283 review: - Log err.name and err.message instead of raw err object to avoid {} serialization in JSON-based loggers, consistent with teardown() and connect() error handling patterns in the same file - Reformat long chained call in connect() for readability
This commit is contained in:
committed by
GitHub
parent
b929ed4203
commit
8158b5e10b
@@ -88,7 +88,15 @@ export function useConnections() {
|
||||
if (conn?.meshDeviceId) {
|
||||
try {
|
||||
useDeviceStore.getState().removeDevice(conn.meshDeviceId);
|
||||
} catch {}
|
||||
} catch (e) {
|
||||
const err = e as Error;
|
||||
log.warn("removeDevice failed during removeConnection", {
|
||||
id,
|
||||
meshDeviceId: conn.meshDeviceId,
|
||||
name: err?.name,
|
||||
message: err?.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
meshRegistry.unregister(id);
|
||||
removeSavedConnectionFromStore(id);
|
||||
@@ -249,7 +257,9 @@ export function useConnections() {
|
||||
// Read from the live store, not the memoized `connections` closure: callers
|
||||
// such as addConnectionAndConnect() add a connection and connect to it in the
|
||||
// same tick, before this hook re-renders, so the closure would be stale.
|
||||
const conn = useDeviceStore.getState().savedConnections.find((c) => c.id === id);
|
||||
const conn = useDeviceStore
|
||||
.getState()
|
||||
.savedConnections.find((c) => c.id === id);
|
||||
if (!conn) {
|
||||
log.warn("connect: unknown connection id", { id });
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user