Open kpgalligan opened 1 year ago
Hi there. Is there any simple/recommended way to log an Swift Error or NSError using kermit?
Currently if you print an error, it's somewhat self sufficient.
enum IntParsingError: Error {
case overflow
}
// Swift
let error = NSError(domain: "MyDomain", code: 123, userInfo: ["Detail" : 789])
print(error)
print(error.localizedDescription)
ErrorTest().logNSError(error: )
ErrorTest().logNSError(error: IntParsingError.overflow)
// Kotlin
class ErrorTest {
fun logNSError(error: NSError) {
Logger.i { error.toString() }
}
}
Error Domain=MyDomain Code=123 "(null)" UserInfo={Detail=789}
The operation couldn’t be completed. (MyDomain error 123.)
🟢 Error Domain=MyDomain Code=123 "(null)" UserInfo={Detail=789}
🟢 KermitSampleIOS.IntParsingError.overflow
There isn't a strict way to log an error, or a logger that takes in an error specifically.
Logger and OSLog don't seem to take in Errors or anything similar.
https://developer.apple.com/documentation/foundation/nserror https://developer.apple.com/documentation/swift/error
Context: https://kotlinlang.slack.com/archives/CTJB58X7X/p1698398439685649