Skip to content

Commit

Permalink
Fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
leoMehlig committed May 9, 2024
1 parent 16b1d20 commit f135719
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 31 deletions.
8 changes: 4 additions & 4 deletions Sources/Auth/AuthClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ public final class AuthClient: Sendable {
#if canImport(UIKit) && !os(watchOS)
var backgroundTaskId: UIBackgroundTaskIdentifier = .invalid
backgroundTaskId = await UIApplication.shared.beginBackgroundTask(withName: "authRefreshSession") { [weak self] in
self?.logger?.debug("Refresh session background task killed.")
Current.logger?.debug("Refresh session background task killed.")
Task { @MainActor [backgroundTaskId] in
UIApplication.shared.endBackgroundTask(backgroundTaskId)
}
Expand All @@ -1064,7 +1064,7 @@ public final class AuthClient: Sendable {
.refreshToken
}

logger?.debug("Refresh called with: \(String(describing: refreshToken))")
Current.logger?.debug("Refresh called with: \(String(describing: refreshToken))")

let session = try await api.execute(
.init(
Expand All @@ -1075,7 +1075,7 @@ public final class AuthClient: Sendable {
)
).decoded(as: Session.self, decoder: configuration.decoder)

logger?.debug("Session obtained, next refreshToken: \(session.refreshToken)")
Current.logger?.debug("Session obtained, next refreshToken: \(session.refreshToken)")

if session.user.phoneConfirmedAt != nil || session.user.emailConfirmedAt != nil
|| session
Expand All @@ -1085,7 +1085,7 @@ public final class AuthClient: Sendable {
eventEmitter.emit(.tokenRefreshed, session: session)
}

logger?.debug("Session updated.")
Current.logger?.debug("Session updated.")

return session
}
Expand Down
4 changes: 1 addition & 3 deletions Sources/Auth/Internal/SessionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ actor SessionManager {
Current.sessionRefresher
}

func session(shouldValidateExpiration: Bool) async throws -> Session {

func session(shouldValidateExpiration: Bool = true) async throws -> Session {
guard let currentSession = try storage.getSession() else {
throw AuthError.sessionNotFound
}
Expand All @@ -42,7 +41,6 @@ actor SessionManager {
}

func update(_ session: Session) throws {
logger?.debug("Updating session")
try storage.storeSession(StoredSession(session: session))
}

Expand Down
11 changes: 11 additions & 0 deletions Sources/_Helpers/SharedModels/HTTPError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ public struct HTTPError: Error, Sendable {
self.response = response
}
}

extension HTTPError: LocalizedError {
public var errorDescription: String? {
var message = "Status Code: \(self.response.statusCode)"
if let body = String(data: data, encoding: .utf8) {
message += " Body: \(body)"
}
return message
}
}

24 changes: 0 additions & 24 deletions Sources/_Helpers/SharedModels/PostgrestError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,3 @@ extension PostgrestError: LocalizedError {
message
}
}

public struct HTTPError: Error, Sendable {
public let response: HTTPURLResponse
public let data: Data

public var statusCode: Int {
response.statusCode
}

public init(response: HTTPURLResponse, data: Data) {
self.response = response
self.data = data
}
}

extension HTTPError: LocalizedError {
public var errorDescription: String? {
var message = "Status Code: \(self.statusCode)"
if let body = String(data: data, encoding: .utf8) {
message += " Body: \(body)"
}
return message
}
}

0 comments on commit f135719

Please sign in to comment.