Releases: FlineDev/ErrorKit
1.2.1
Adding Logger Conveniences
Since string interpolation (added in 1.2.0) only works where a String is expected, the last release doesn't help with Logger where OSLogMessage is expected. This version introduces convenience APIs so the errorChainDescription can be easily printed in those cases.
For OSLog/Logger there are now dedicated convenience overloads taking a second error parameter:
// Instead of:
Logger().error("Update failed:\n\(ErrorKit.errorChainDescription(for: error))")
// You can simply use overloads like:
Logger().error("Update failed", error: error)
Logger().warning("Update failed", error: error)Note that there's no need to add a colon (:) or newline (\n) to the message, they will be added automatically.
Full Changelog: 1.2.0...1.2.1
1.2.0
String Interpolation Convenience
ErrorKit now provides convenient string interpolation for errors, making it effortless to display user-friendly messages and debug error chains.
User-Friendly Error Messages
// Instead of:
showAlert(message: "Save failed: \(ErrorKit.userFriendlyMessage(for: error))")
// You can now simply use:
showAlert(message: "Save failed: \(error)")
Text("Could not load data: \(error)")If you were using this kind of interpolation for errors, you get improved error messages just by adding ErrorKit to your project without any changes needed! 🥳
Error Chain Debugging
// Instead of:
print("Update failed: \(ErrorKit.errorChainDescription(for: error))")
// You can now use either:
print("Update failed:\n\(chain: error)")
print("Update failed:\n\(debug: error)")Both chain: and debug: are aliases — use whichever feels more natural to you.
What's Changed
- Add StringInterpolation helpers to render errors by @finestructure in #37
New Contributors
- @finestructure made their first contribution in #37
Full Changelog: 1.1.0...1.2.0