import Foundation

@MainActor
func hermesUserFacingErrorMessage(localization: LocalizationStore, localeCode: String, error: Error?) -> String? {
    guard let error else {
        return nil
    }

    if error is CancellationError {
        return nil
    }

    if error is URLError {
        return localization.string(for: "errors.network", localeCode: localeCode)
    }

    if error is HermesAPIError {
        return localization.string(for: "errors.generic", localeCode: localeCode)
    }

    return localization.string(for: "errors.generic", localeCode: localeCode)
}
