create_buffer_from file return nullptr on file not found instead of throwing

This commit is contained in:
Maxime Coste 2012-10-16 14:59:39 +02:00
parent 4be6882bd5
commit 6ff6058ceb
2 changed files with 3 additions and 7 deletions

View File

@ -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);

View File

@ -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));
}