forked from RocketChat/Rocket.Chat.iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPIError.swift
More file actions
34 lines (29 loc) · 906 Bytes
/
Copy pathAPIError.swift
File metadata and controls
34 lines (29 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// APIError.swift
// Rocket.Chat
//
// Created by Matheus Cardoso on 11/27/17.
// Copyright © 2017 Rocket.Chat. All rights reserved.
//
import Foundation
typealias APIErrored = (APIError) -> Void
enum APIError: CustomStringConvertible {
case version(available: Version, required: Version)
case error(Error)
case noData
case malformedRequest
case notSecured
var description: String {
switch self {
case .error(let error):
return error.localizedDescription
default:
return Mirror(reflecting: self).children.first?.label ?? "unknown"
}
}
}
extension NSError {
static var sslErrors: [Int] {
return [NSURLErrorSecureConnectionFailed, NSURLErrorServerCertificateUntrusted, NSURLErrorServerCertificateHasBadDate, NSURLErrorServerCertificateNotYetValid, NSURLErrorServerCertificateHasUnknownRoot]
}
}