summaryrefslogtreecommitdiff
path: root/Hutch/Networking/SystemStatusRepository.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-13 14:20:27 -0500
committerChristian Cleberg <[email protected]>2026-04-13 14:20:27 -0500
commit5e63048ab6a741ae947f7fe42efcb5206a3f3963 (patch)
treecf8eb2e3bc3b2edb20ef96a2599e684378120e5b /Hutch/Networking/SystemStatusRepository.swift
parent0b84ecaf7ba0fb2cd3f3867da8dc732450b55b50 (diff)
downloadhutch-5e63048ab6a741ae947f7fe42efcb5206a3f3963.tar.gz
hutch-5e63048ab6a741ae947f7fe42efcb5206a3f3963.tar.bz2
hutch-5e63048ab6a741ae947f7fe42efcb5206a3f3963.zip
fix: mercurial parity and graphql handlingv3.0.4
- implements consistent UX between repo types - ensures centralized services and routes are used between repo types - graphql error handling is centralized - error messages are consistent Implements: https://todo.sr.ht/~ccleberg/hutch/58 Implements: https://todo.sr.ht/~ccleberg/hutch/59
Diffstat (limited to 'Hutch/Networking/SystemStatusRepository.swift')
-rw-r--r--Hutch/Networking/SystemStatusRepository.swift51
1 files changed, 1 insertions, 50 deletions
diff --git a/Hutch/Networking/SystemStatusRepository.swift b/Hutch/Networking/SystemStatusRepository.swift
index 5f51315..028c64e 100644
--- a/Hutch/Networking/SystemStatusRepository.swift
+++ b/Hutch/Networking/SystemStatusRepository.swift
@@ -130,56 +130,7 @@ actor SystemStatusRepository {
}
private func refreshErrorMessage(from error: any Error) -> String {
- if let error = error as? SRHTError {
- switch error {
- case .graphQLErrors(let errors):
- let firstMessage = errors.first?.message.lowercased() ?? ""
- if firstMessage.contains("unauthorized") || firstMessage.contains("forbidden") {
- return "You do not have permission to do that."
- }
- if firstMessage.contains("not found") || firstMessage.contains("no rows in result set") {
- return "That content is no longer available."
- }
- return "Something went wrong. Please try again."
- case .httpError(let code):
- if code == 401 {
- return "Please sign in again."
- }
- if code == 403 {
- return "You do not have permission to do that."
- }
- if code == 404 {
- return "That content is no longer available."
- }
- if (500...599).contains(code) {
- return "The server is unavailable right now. Please try again."
- }
- return "Something went wrong. Please try again."
- case .invalidAuthenticatedURL:
- return "That request could not be completed."
- case .decodingError:
- return "The response could not be loaded right now."
- case .networkError(let underlyingError):
- return refreshErrorMessage(from: underlyingError)
- case .unauthorized:
- return "Please sign in again."
- }
- }
-
- let nsError = error as NSError
- switch nsError.code {
- case NSURLErrorNotConnectedToInternet,
- NSURLErrorNetworkConnectionLost,
- NSURLErrorTimedOut,
- NSURLErrorCannotFindHost,
- NSURLErrorCannotConnectToHost,
- NSURLErrorDNSLookupFailed,
- NSURLErrorInternationalRoamingOff,
- NSURLErrorDataNotAllowed:
- return "Check your connection and try again."
- default:
- return "Something went wrong. Please try again."
- }
+ error.userFacingMessage
}
}