-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataLayerError.swift
More file actions
59 lines (52 loc) · 1.38 KB
/
Copy pathDataLayerError.swift
File metadata and controls
59 lines (52 loc) · 1.38 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// DataLayerError.swift
// DevLogData
//
// Created by opfic on 3/11/26.
//
import AuthenticationServices
import Foundation
import DevLogCore
public enum EmailFetchError: Error, Equatable {
case emailNotFound
case emailMismatch
public var code: String {
switch self {
case .emailMismatch:
"email_mismatch"
case .emailNotFound:
"email_not_found"
}
}
}
public enum DataError: Error {
case invalidData(context: String)
private static let logger = Logger(category: "DataError")
public static func invalidData(
_ context: String,
file: String = #file,
function: String = #function,
line: Int = #line
) -> DataError {
logger.error(
"Invalid data: \(context)",
file: file,
function: function,
line: line
)
return .invalidData(context: context)
}
}
public extension Error {
var isSocialLoginCancelled: Bool {
switch self {
case let authError as ASAuthorizationError:
return authError.code == .canceled
case let webAuthError as ASWebAuthenticationSessionError:
return webAuthError.code == .canceledLogin
default:
let nsError = self as NSError
return nsError.domain == "com.google.GIDSignIn" && nsError.code == -5
}
}
}