shekhar23/claude-zero-to-hero-android-kmp/android-error-handling
Claude Code and agent skill by shekhar23/claude-zero-to-hero-android-kmp
- community
Checking that the SKILL.md file is still in the repository.
Generic Result wrapper, error types, and extension helpers for Android/KMP - Result<T, E>, DataError, EmptyResult, map, onSuccess, onFailure. Use this skill whenever defining error types, creating a Result wrapper, handling success/failure flows, mapping errors, or working with typed errors anywhere in the app (not just data layer — also validation, auth, domain logic). Trigger on phrases like "Result wrapper", "error handling", "DataError", "onSuccess", "onFailure", "EmptyResult", "map result", "error type", "validation error", or "typed errors".
Install
npx vskill@latest install shekhar23/claude-zero-to-hero-android-kmp/android-error-handlingSKILL.md
Android / KMP Error Handling
Result Wrapper (core:domain)
A generic, typed Result that works across all layers — data, domain, presentation, validation, anywhere a function can succeed or fail with a typed error.
Extension Helpers (core:domain)
These live alongside the Result definition:
All helpers return Result so they can be chained:
Shared Error Types (core:domain)
DataError
Feature-Specific Errors
Features define their own error types by implementing Error:
Multiple validation errors are not supported — always return a single error type per Result.
Exception Handling Philosophy
Never throw exceptions for expected failures — always return Result.Error. Catch exceptions at the layer that is responsible for the exception:
| Exception origin | Catch in | Example | |
|---|---|---|---|
| HTTP / network | Data layer | UnresolvedAddressException → DataError.Network.NO_INTERNET | |
| Database / disk | Data layer | SQLiteFullException → DataError.Local.DISK_FULL | |
| Business logic | Domain layer | Invalid input → Result.Error(ValidationError.TOO_SHORT) | |
| Presentation | Presentation layer | Catch and map to Result.Error at that layer |
The layer that owns the exception catches it and converts it to a typed Result.Error. Upper layers never see raw exceptions for expected failures.
Mapping Errors to UiText
Every error type that is displayed to the user should have a .toUiText() extension function. Place it in:
- Feature's `presentation` module — if the error is feature-specific (e.g.,
AuthError.toUiText()) - `core:presentation` — if the error is shared across features (e.g.,
DataError.toUiText())
If an error is purely internal and never shown to the user (e.g., a retry signal, an internal state marker), it does not need a .toUiText() mapping.
Safe Call Helpers (core:data)
Typed extension functions on HttpClient that wrap Ktor calls and map HTTP responses to Result<T, DataError.Network>:
Usage in a data source is clean and uniform:
When to Use What
| Scenario | Error type | Example return | |
|---|---|---|---|
| Network call | DataError.Network | Result<List<NoteDto>, DataError.Network> | |
| Local DB access | DataError.Local | Result<Note, DataError.Local> | |
| Repository (multi-source) | DataError (supertype) | Result<List<Note>, DataError> | |
| Domain validation | Custom Error enum | EmptyResult<PasswordValidationError> | |
| Auth logic | Custom Error enum | Result<User, AuthError> |
The Result wrapper is not limited to the data layer — use it anywhere a function has typed success and failure outcomes.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/android-error-handling/SKILL.md
Popularity
- Repository stars
- 9
- Repository forks
- 5
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 30 Sep 2026, a month ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/shekhar23/claude-zero-to-hero-android-kmp/android-error-handling)