 
     private func selectChannel(_ channel: Channel) {
         guard let channels = SomaAPI.channels, let selectedChannelIdx = channels.index(where: { $0.id == channel.id }) else { return }
+        guard reachability.connection != .none else {
+            showConnectionError()
+            return
+        }
 
         stationsMenu.items.forEach { $0.state = $0.tag == selectedChannelIdx ? .on : .off }
 

//  Copyright © 2017 Evgeny Aleksandrov. All rights reserved.

import Cocoa

class MenubarController {
    let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)

        notification.informativeText = trackName
        NSUserNotificationCenter.default.deliver(notification)
    }

    // MARK: - Reachability

    let reachability = Reachability(hostname: "api.somafm.com")!

    private func setupReachability() {
        reachability.whenReachable = { _ in
            self.updateTrackName()
        }
        reachability.whenUnreachable = { _ in
            self.updateTrackName()
        }
        do {
            try reachability.startNotifier()
        } catch {
            Log.error("Reachability error")
        }
    }

    private func showConnectionError() {
        setStatusItem(playing: true)

        let notification = NSUserNotification()
        notification.title = "Network error"
        notification.informativeText = "Can't connect to SomaFM.com"
        NSUserNotificationCenter.default.deliver(notification)

        DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
            self.setStatusItem(playing: false)
        }
    }
}
