1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-25 23:02:35 +03:00

GH-360 Show reason when the IPC got invalid

This commit is contained in:
Tae Won Ha 2016-12-05 22:05:38 +01:00
parent 16c35ba682
commit a4fbdfff39
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
5 changed files with 12 additions and 9 deletions

View File

@ -395,7 +395,9 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
if (responseCode != kCFMessagePortSuccess) {
log_cfmachport_error(responseCode, msgid, data);
[_bridge ipcBecameInvalid];
[_bridge ipcBecameInvalid:
[NSString stringWithFormat:@"Reason: sendMsg failed for %d with %d", msgid, responseCode]
];
return nil;
}

View File

@ -123,7 +123,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)stop;
- (void)ipcBecameInvalid;
- (void)ipcBecameInvalid:(NSString *)reason;
@end

View File

@ -89,7 +89,7 @@ public class NeoVimView: NSView, NeoVimUiBridgeProtocol, NSUserInterfaceValidati
public var cwd: URL {
get {
guard let output = self.agent.vimCommandOutput("silent pwd") else {
self.ipcBecameInvalid()
self.ipcBecameInvalid("Reason: 'silent pwd' failed")
return URL(fileURLWithPath: NSHomeDirectory())
}
@ -730,7 +730,7 @@ extension NeoVimView {
}
guard let curPasteMode = self.agent.boolOption("paste") else {
self.ipcBecameInvalid()
self.ipcBecameInvalid("Reason: 'set paste' failed")
return
}
@ -1438,10 +1438,10 @@ extension NeoVimView {
}
}
public func ipcBecameInvalid() {
public func ipcBecameInvalid(_ reason: String) {
NSLog("ERROR \(#function): force-quitting")
DispatchUtils.gui {
self.delegate?.ipcBecameInvalid()
self.delegate?.ipcBecameInvalid(reason: reason)
self.agent.quit()
}
}

View File

@ -14,5 +14,5 @@ public protocol NeoVimViewDelegate: class {
func cwdChanged()
func bufferListChanged()
func ipcBecameInvalid()
func ipcBecameInvalid(reason: String)
}

View File

@ -483,11 +483,12 @@ extension MainWindowComponent {
self.publish(event: MainWindowAction.changeBufferList(mainWindow: self, buffers: buffers))
}
func ipcBecameInvalid() {
func ipcBecameInvalid(reason: String) {
let alert = NSAlert()
alert.addButton(withTitle: "Close")
alert.messageText = "Sorry, an error occurred."
alert.informativeText = "VimR encountered an error from which it cannot recover. This window will now close."
alert.informativeText = "VimR encountered an error from which it cannot recover. This window will now close.\n"
+ reason
alert.alertStyle = .critical
alert.beginSheetModal(for: self.window) { [weak self] response in
self?.windowController.close()