Files
Outpost/Outpost/Support/OutlineAPIError+Message.swift
T
Puranjay Savar Mattas 654ec94b80 feat(search): add contextual and workspace-wide document search
Two entry points backed by documents.search: a per-collection toolbar
search field, and a sidebar-driven global search with collection/date/
sort/status filters. Both debounce via .task(id:) instead of a timer.
2026-08-14 00:24:22 +01:00

30 lines
1.1 KiB
Swift

import Foundation
import OutlineKit
extension OutlineAPIError {
/// User-facing message, distinguishing failure causes instead of one blanket
/// "try again" — a 404 (e.g. an endpoint missing on an older server version)
/// looks nothing like a dropped connection, and surfacing that difference is
/// what actually helps diagnose it.
var userFacingMessage: String {
switch self {
case .unauthorized:
return "Sign-in expired. Try signing in again."
case .notFound:
return "That isn't available on this server."
case .transport:
return "Couldn't reach the server. Check your connection."
case .server(let status, let message):
return message ?? "The server returned an error (\(status))."
case .decoding:
return "Got an unexpected response from the server."
case .tokenUnavailable:
return "Couldn't access your saved sign-in."
}
}
}
func outlineErrorMessage(_ error: Error, fallback: String) -> String {
(error as? OutlineAPIError)?.userFacingMessage ?? fallback
}