forked from shadowfacts/Tusker
Don't capture certain error types
This commit is contained in:
parent
c114749519
commit
521c46c0be
|
@ -56,37 +56,7 @@ extension ToastConfiguration {
|
|||
viewController.present(reporter, animated: true)
|
||||
}
|
||||
// TODO: this is a bizarre place to do this, but code path covers basically all errors
|
||||
switch error.type {
|
||||
case .invalidRequest, .invalidResponse, .invalidModel(_), .mastodonError(_, _):
|
||||
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:
|
||||
event.tags!["error_type"] = "invalid_request"
|
||||
case .invalidResponse:
|
||||
event.tags!["error_type"] = "invalid_response"
|
||||
case .invalidModel(let error):
|
||||
event.tags!["error_type"] = "invalid_model"
|
||||
event.extra = [
|
||||
"underlying_error": String(describing: error)
|
||||
]
|
||||
case .mastodonError(let code, let error):
|
||||
event.tags!["error_type"] = "mastodon_error"
|
||||
event.tags!["response_code"] = "\(code)"
|
||||
event.extra = [
|
||||
"underlying_error": String(describing: error)
|
||||
]
|
||||
default:
|
||||
break
|
||||
}
|
||||
SentrySDK.capture(event: event)
|
||||
default:
|
||||
break
|
||||
}
|
||||
captureError(error, title: title)
|
||||
} else {
|
||||
self.subtitle = error.localizedDescription
|
||||
self.systemImageName = "exclamationmark.triangle"
|
||||
|
@ -116,3 +86,39 @@ fileprivate extension Pachyderm.Client.Error {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func captureError(_ error: Client.Error, title: String) {
|
||||
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:
|
||||
event.tags!["error_type"] = "invalid_request"
|
||||
case .invalidResponse:
|
||||
event.tags!["error_type"] = "invalid_response"
|
||||
case .invalidModel(let error):
|
||||
event.tags!["error_type"] = "invalid_model"
|
||||
event.extra = [
|
||||
"underlying_error": String(describing: error)
|
||||
]
|
||||
case .mastodonError(let code, let error):
|
||||
event.tags!["error_type"] = "mastodon_error"
|
||||
event.tags!["response_code"] = "\(code)"
|
||||
event.extra = [
|
||||
"underlying_error": String(describing: error)
|
||||
]
|
||||
case .unexpectedStatus(let code):
|
||||
event.tags!["error_type"] = "unexpected_status"
|
||||
event.tags!["response_code"] = "\(code)"
|
||||
default:
|
||||
return
|
||||
}
|
||||
if let code = event.tags!["response_code"],
|
||||
code == "401" || code == "403" {
|
||||
return
|
||||
}
|
||||
SentrySDK.capture(event: event)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue