diff --git a/src/commands.cc b/src/commands.cc index 97db7e5f..81fb5fb1 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -216,12 +216,8 @@ private: Buffer* open_or_create(const String& filename, Context& context) { - Buffer* buffer = NULL; - try - { - buffer = create_buffer_from_file(filename); - } - catch (file_not_found& what) + Buffer* buffer = create_buffer_from_file(filename); + if (not buffer) { context.print_status("new file " + filename); buffer = new Buffer(filename, Buffer::Type::NewFile); diff --git a/src/file.cc b/src/file.cc index b05b5782..ad98e613 100644 --- a/src/file.cc +++ b/src/file.cc @@ -76,7 +76,7 @@ Buffer* create_buffer_from_file(const String& filename) if (fd == -1) { if (errno == ENOENT) - throw file_not_found(filename); + return nullptr; throw file_access_error(filename, strerror(errno)); }