.NET MAUI › Best Practices & Architecture
How do you handle errors and show user-friendly messages centrally?
IntermediateAnswer
Catch exceptions at boundaries (service calls, commands), log them via a logging/telemetry abstraction, and surface a friendly message through a shared dialog/toast service. Avoid swallowing exceptions silently; distinguish expected failures (validation, offline) from unexpected ones and only crash on truly unrecoverable states.
try { await _svc.SaveAsync(); }
catch (HttpRequestException) { await _dialogs.AlertAsync("You appear offline."); }
catch (Exception ex) { _log.Error(ex); await _dialogs.AlertAsync("Something went wrong."); }Real-world example All command handlers route errors through one dialog service, giving consistent, friendly messaging and centralized logging.