fix(oxibadge): show connection errors instead of failing silently
Check, format and test / build (push) Successful in 10m4s

load_records/load_employees failures were only logged to the console
and silently reset the UI to the month picker. Errors now flow through
a shared store (src/lib/error.ts) into an ErrorBanner, reused by both
Onboarding and ConfirmMonth, with the raw message passed straight
through from Rust (no stable-code classification layer — these are
mostly plain I/O errors, not worth categorizing).

i18n stays grouped per screen as before, with error-related strings
split into their own top-level "errors" group.

Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-07 13:26:01 +02:00
parent 28186c7745
commit b4cd8e1796
7 changed files with 47 additions and 56 deletions
+5 -17
View File
@@ -22,27 +22,15 @@ async fn test_connection(host: String, port: u16) -> Result<(), String> {
connect_with_retries(&host, port).await.map(|_| ())
}
/// Connects to the device, trying up to 3 times, returning a stable error
/// code (not a user-facing message) on failure so the frontend can
/// translate it.
/// Connects to the device, trying up to 3 times, returning the last error
/// message as-is on failure.
async fn connect_with_retries(host: &str, port: u16) -> Result<R701, String> {
let mut last_error = String::new();
for _ in 0..3 {
let err = match R701::connect((host, port)).await {
match R701::connect((host, port)).await {
Ok(r701) => return Ok(r701),
Err(err) => err,
};
last_error = match err.kind() {
std::io::ErrorKind::ConnectionRefused => "connection-refused".to_string(),
std::io::ErrorKind::TimedOut => "timed-out".to_string(),
_ if err
.to_string()
.contains("failed to lookup address information") =>
{
"dns-failure".to_string()
}
_ => "unknown".to_string(),
};
Err(err) => last_error = err.to_string(),
}
}
Err(last_error)
}