I had set up NewRelic in my iOS app for the first time but wasn’t sure if my recorded errors were coming through. So here’s the most basic way I found to test error handling. Credit — this is based on Edward Brey’s example on StackOverflow. Thanks, Edward!
struct SomeKindOfError: Error, LocalizedError {
let errorDescription: String? init(_ description: String) {
errorDescription = description
}
}
do {
throw SomeKindOfError("Description goes here")
} catch let error {
NewRelic.recordError(error, attributes: [ "message": "This is my test error" ])
}
Thanks for reading! I hope this helps someone. If you’re having trouble finding the recordError
output in the NewRelic interface, check out my guide on that.