Introduce error_string() as a portable replacement for strerror_r()

This commit is contained in:
Joe Thornber
2015-01-16 12:54:09 +00:00
parent f1130198e1
commit 25b4b526f4
5 changed files with 17 additions and 13 deletions

View File

@@ -18,13 +18,14 @@
#include "block.h"
#include "base/error_string.h"
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <boost/bind.hpp>
#include <stdexcept>
@@ -44,11 +45,8 @@ namespace {
// FIXME: introduce a new exception for this, or at least lift this
// to exception.h
void syscall_failed(char const *call) {
char buffer[128];
char *msg = strerror_r(errno, buffer, sizeof(buffer));
ostringstream out;
out << "syscall '" << call << "' failed: " << msg;
out << "syscall '" << call << "' failed: " << base::error_string(errno);;
throw runtime_error(out.str());
}