From 6ff6058cebd1e501207c9b3b43ee5e4d0fd4d218 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 16 Oct 2012 14:59:39 +0200 Subject: [PATCH] create_buffer_from file return nullptr on file not found instead of throwing --- src/commands.cc | 8 ++------ src/file.cc | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) 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)); }