From 4a96926c4b438f66c1b86ea3345c375189b33973 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 5 Feb 2018 20:26:44 +1100 Subject: [PATCH] Handle errors while reloading buffer gracefully Fixes #1831 --- src/client.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/client.cc b/src/client.cc index b2199194..5b6e2866 100644 --- a/src/client.cc +++ b/src/client.cc @@ -274,9 +274,18 @@ void Client::force_redraw() void Client::reload_buffer() { Buffer& buffer = context().buffer(); - reload_file_buffer(buffer); - context().print_status({ format("'{}' reloaded", buffer.display_name()), - get_face("Information") }); + try + { + reload_file_buffer(buffer); + context().print_status({ format("'{}' reloaded", buffer.display_name()), + get_face("Information") }); + } + catch (runtime_error& error) + { + context().print_status({ format("error while reloading buffer: '{}'", error.what()), + get_face("Error") }); + buffer.set_fs_timestamp(get_fs_timestamp(buffer.name())); + } } void Client::on_buffer_reload_key(Key key)