diff --git a/Sources/SocketKit/Socket/Socket.swift b/Sources/SocketKit/Socket/Socket.swift index c07c289..f435a16 100644 --- a/Sources/SocketKit/Socket/Socket.swift +++ b/Sources/SocketKit/Socket/Socket.swift @@ -71,7 +71,7 @@ extension Socket: SocketManager { // MARK: - Socket Function extension Socket { - public func subscribe(for event: String, on channel: String, handler: @escaping (Result) -> Void) { + public func subscribe(for event: String, on channel: String, handler: @escaping (Result) -> Void) { guard let channel = pusher.connection.channels.channels.first(where: { $0.key == channel }) else { @@ -98,7 +98,7 @@ extension Socket { handler(.success(result)) } catch let error { - handler(.failure(.parsingError(error))) + handler(.failure(SocketError.parsingError(error))) } } } diff --git a/Sources/SocketKit/Socket/SocketError.swift b/Sources/SocketKit/Socket/SocketError.swift index f445645..cc8c91b 100644 --- a/Sources/SocketKit/Socket/SocketError.swift +++ b/Sources/SocketKit/Socket/SocketError.swift @@ -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)" + } + } }