create_buffer_from file return nullptr on file not found instead of throwing
This commit is contained in:
parent
4be6882bd5
commit
6ff6058ceb
|
@ -216,12 +216,8 @@ private:
|
||||||
|
|
||||||
Buffer* open_or_create(const String& filename, Context& context)
|
Buffer* open_or_create(const String& filename, Context& context)
|
||||||
{
|
{
|
||||||
Buffer* buffer = NULL;
|
Buffer* buffer = create_buffer_from_file(filename);
|
||||||
try
|
if (not buffer)
|
||||||
{
|
|
||||||
buffer = create_buffer_from_file(filename);
|
|
||||||
}
|
|
||||||
catch (file_not_found& what)
|
|
||||||
{
|
{
|
||||||
context.print_status("new file " + filename);
|
context.print_status("new file " + filename);
|
||||||
buffer = new Buffer(filename, Buffer::Type::NewFile);
|
buffer = new Buffer(filename, Buffer::Type::NewFile);
|
||||||
|
|
|
@ -76,7 +76,7 @@ Buffer* create_buffer_from_file(const String& filename)
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
throw file_not_found(filename);
|
return nullptr;
|
||||||
|
|
||||||
throw file_access_error(filename, strerror(errno));
|
throw file_access_error(filename, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user