More tweaks to automatic error reporting

This commit is contained in:
Shadowfacts 2023-01-02 15:14:28 -05:00
parent acd48a6db4
commit a5fc35d0b1
1 changed files with 20 additions and 23 deletions

View File

@ -58,30 +58,27 @@ extension ToastConfiguration {
// TODO: this is a bizarre place to do this, but code path covers basically all errors
switch error.type {
case .invalidRequest, .invalidResponse, .invalidModel(_), .mastodonError(_):
SentrySDK.capture(error: error) { scope in
scope.setFingerprint([String(describing: error)])
let crumb = Breadcrumb(level: .error, category: "error")
crumb.message = title
crumb.data = [
let event = Event(error: error)
event.message = SentryMessage(formatted: "\(title): \(error)")
event.tags = [
"request_method": error.requestMethod.name,
"request_endpoint": error.requestEndpoint.description,
]
switch error.type {
case .invalidRequest:
crumb.data!["error_type"] = "invalid_request"
event.tags!["error_type"] = "invalid_request"
case .invalidResponse:
crumb.data!["error_type"] = "invalid_response"
event.tags!["error_type"] = "invalid_response"
case .invalidModel(let error):
crumb.data!["error_type"] = "invalid_model"
crumb.data!["underlying_error"] = String(describing: error)
event.tags!["error_type"] = "invalid_model"
event.tags!["underlying_error"] = String(describing: error)
case .mastodonError(let error):
crumb.data!["error_type"] = "mastodon_error"
crumb.data!["underlying_error"] = error
event.tags!["error_type"] = "mastodon_error"
event.tags!["underlying_error"] = error
default:
break
}
scope.add(crumb)
}
SentrySDK.capture(event: event)
default:
break
}