Skip to content

Standardize error handling in MusicAssistantManager#66

Merged
chrisuthe merged 1 commit intomainfrom
fix/consistent-error-handling
Mar 8, 2026
Merged

Standardize error handling in MusicAssistantManager#66
chrisuthe merged 1 commit intomainfrom
fix/consistent-error-handling

Conversation

@chrisuthe
Copy link
Copy Markdown
Owner

Summary

  • Replaced inconsistent try/catch blocks in login(), authWithToken(), and connectWithToken() with the runCatching/Result<T> pattern already used by all other command methods in the class
  • Extracted handleConnectionFailure() and connectTransport() private helpers, eliminating ~100 lines of duplicated error-handling and transport setup code
  • Changed login() and authWithToken() return types from Boolean to Result<Unit> for consistency; updated the single caller in MainActivity.kt

Test plan

  • Verify MA login flow works (enter credentials -> connects successfully)
  • Verify invalid credentials show error and allow retry
  • Verify token-based reconnection works on app restart
  • Verify network errors during connection show appropriate error state
  • Unit tests pass (./gradlew testDebugUnitTest)

Replace inconsistent try/catch blocks in login(), authWithToken(), and
connectWithToken() with the runCatching/Result<T> pattern used by all
other command methods. Extract shared helpers (handleConnectionFailure,
connectTransport) to eliminate ~100 lines of duplicated error-handling
code.

- login() and authWithToken() now return Result<Unit> instead of Boolean
- connectWithToken() uses runCatching internally
- Updated the one caller in MainActivity.kt
@chrisuthe chrisuthe merged commit e64ff29 into main Mar 8, 2026
@chrisuthe chrisuthe deleted the fix/consistent-error-handling branch March 8, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant