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