mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-25 06:43:24 +03:00
Add connection error handling for NvimApi usage
This commit is contained in:
parent
040777594f
commit
89393e4da3
@ -89,7 +89,7 @@ static void socket_call_back(
|
||||
if ((_native_socket = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
|
||||
NSLog(@"Error: Unix domain socket NULL!");
|
||||
return [NSError errorWithDomain:NSPOSIXErrorDomain code:-1 userInfo:@{
|
||||
NSLocalizedDescriptionKey: @"Unix domain socket is NULL.",
|
||||
NSLocalizedDescriptionKey: @"Could not create unix domain socket.",
|
||||
}];
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ static void socket_call_back(
|
||||
}
|
||||
|
||||
- (void)disconnectAndStop {
|
||||
if (CFSocketIsValid(_socket)) {
|
||||
if (_socket != NULL && CFSocketIsValid(_socket)) {
|
||||
CFRunLoopStop(_run_loop);
|
||||
CFSocketInvalidate(_socket);
|
||||
[_thread cancel];
|
||||
|
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import Cocoa
|
||||
import NvimMsgPack
|
||||
|
||||
extension NvimView {
|
||||
|
||||
@ -57,7 +58,14 @@ extension NvimView {
|
||||
self.logger.info("=== Starting neovim...")
|
||||
let noErrorDuringInitialization = self.uiClient.runLocalServerAndNeoVim(withWidth: size.width, height: size.height)
|
||||
|
||||
try? self.nvim.connect()
|
||||
do {
|
||||
try self.nvim.connect()
|
||||
} catch {
|
||||
logger.fault("Could not connect to nvim: \(error)")
|
||||
self.nvim.disconnect()
|
||||
self.ipcBecameInvalid(String(describing: error))
|
||||
return
|
||||
}
|
||||
|
||||
if noErrorDuringInitialization == false {
|
||||
self.logger.fault("There was an error launching neovim.")
|
||||
|
@ -218,6 +218,7 @@ extension NvimView {
|
||||
self.delegate?.ipcBecameInvalid(reason: reason)
|
||||
|
||||
self.bridgeLogger.error("Force-closing due to IPC error.")
|
||||
self.nvim.disconnect()
|
||||
self.uiClient.forceQuit()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user