io: use more appropriate exceptions in fd_ref
This commit is contained in:
parent
8df51f7830
commit
f559f3d912
12
io.cpp
12
io.cpp
@ -25,11 +25,13 @@
|
|||||||
#include "types/casts.hpp"
|
#include "types/casts.hpp"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -95,8 +97,8 @@ util::write (const boost::filesystem::path &path, const char *data, size_t len)
|
|||||||
fd_ref::fd_ref (int _fd):
|
fd_ref::fd_ref (int _fd):
|
||||||
fd (_fd)
|
fd (_fd)
|
||||||
{
|
{
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
throw invalid_argument ("invalid file descriptor");
|
throw std::invalid_argument ("invalid descriptor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -108,7 +110,7 @@ fd_ref::fd_ref (const boost::filesystem::path &path, int flags):
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
throw path_error (path);
|
util::errno_error::throw_code ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user