mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-23 07:15:52 +03:00
create_buffer_from_file: throw file_not_found instead of open_file_error when ENOENT
This commit is contained in:
parent
955744e5d0
commit
11d82b11b3
@ -14,7 +14,12 @@ Buffer* create_buffer_from_file(const std::string& filename)
|
||||
{
|
||||
int fd = open(filename.c_str(), O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
if (errno == ENOENT)
|
||||
throw file_not_found(strerror(errno));
|
||||
|
||||
throw open_file_error(strerror(errno));
|
||||
}
|
||||
|
||||
std::string content;
|
||||
char buf[256];
|
||||
|
@ -13,6 +13,12 @@ struct open_file_error : public std::runtime_error
|
||||
: std::runtime_error(what) {}
|
||||
};
|
||||
|
||||
struct file_not_found : public open_file_error
|
||||
{
|
||||
file_not_found(const std::string& what)
|
||||
: open_file_error(what) {}
|
||||
};
|
||||
|
||||
struct write_file_error : public std::runtime_error
|
||||
{
|
||||
write_file_error(const std::string& what)
|
||||
|
Loading…
Reference in New Issue
Block a user