https://github.com/nashysolutions/error-presentation
A lightweight Swift package for presenting clean, localised, user-friendly error messages in SwiftUI and UIKit.
https://github.com/nashysolutions/error-presentation
dependency-injection error-handling localized-errors spm swift swiftui testability user-facing-errors
Last synced: 8 months ago
JSON representation
A lightweight Swift package for presenting clean, localised, user-friendly error messages in SwiftUI and UIKit.
- Host: GitHub
- URL: https://github.com/nashysolutions/error-presentation
- Owner: nashysolutions
- License: mit
- Created: 2025-06-10T03:03:35.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-06-15T01:18:43.000Z (10 months ago)
- Last Synced: 2025-07-04T11:48:03.454Z (9 months ago)
- Topics: dependency-injection, error-handling, localized-errors, spm, swift, swiftui, testability, user-facing-errors
- Language: Swift
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Error Presentation
[](https://swiftpackageindex.com/nashysolutions/error-presentation)
[](https://swiftpackageindex.com/nashysolutions/error-presentation)
A lightweight Swift package for defining **clean, user-friendly, localised error messages**.
This package introduces a single, purposeful protocol — `LocalizedCustomerFacingError` — to help you avoid leaking internal details into your user interface, while still supporting developer-friendly logging and diagnostics.
---
## Usage
```swift
enum LoginError: LocalizedCustomerFacingError {
case invalidPassword
var userFriendlyLocalizedDescription: String {
String(localized: "login.invalidPassword", defaultValue: "Your password is incorrect.")
}
}
```
Use in SwiftUI
```swift
.alert(item: $error) { error in
Alert(title: Text(error.localizedDescription))
}
```
And log developer-friendly details separately:
```swift
extension LoginError: CustomDebugStringConvertible {
var debugDescription: String {
"LoginError.invalidPassword: Password did not match server response"
}
}
logger.debug("Login failed: \(error)")
```