Skip to content

Commit

Permalink
Merge pull request #8 from MohammadRezaAnsari/develop
Browse files Browse the repository at this point in the history
Fix dependency of other packages to SocketError
  • Loading branch information
MohammadRezaAnsari authored Aug 8, 2021
2 parents 743fc13 + 6c0c3b1 commit 701836a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/SocketKit/Socket/Socket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ extension Socket: SocketManager {
// MARK: - Socket Function
extension Socket {

public func subscribe<T: Codable>(for event: String, on channel: String, handler: @escaping (Result<T, SocketError>) -> Void) {
public func subscribe<T: Codable>(for event: String, on channel: String, handler: @escaping (Result<T, Error>) -> Void) {

guard let channel = pusher.connection.channels.channels.first(where: { $0.key == channel }) else {

Expand All @@ -98,7 +98,7 @@ extension Socket {
handler(.success(result))
}
catch let error {
handler(.failure(.parsingError(error)))
handler(.failure(SocketError.parsingError(error)))
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions Sources/SocketKit/Socket/SocketError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ public enum SocketError: Error {
case .parsingError(let error): return "Parsing event data got error: \(error.localizedDescription)"
}
}

public var localizedDescription: String {
switch self {
case .emptyOption: return "There is no option."
case .channelExist: return "The channel currently is subscribing."
case .noChannel: return "There is no channel with given name."
case .parsingError(let error): return "Parsing event data got error: \(error.localizedDescription)"
}
}
}

0 comments on commit 701836a

Please sign in to comment.