master
cpp 23 lines 688 Bytes
Raw
1 // Copyright (C) Microsoft Corporation. All rights reserved.
2 #include <sstream>
3 #include <string.h>
4 #include "SyscallError.h"
5
6 SyscallError::SyscallError(const std::string& method, const std::string& arguments, int err, const std::source_location& source) :
7 RuntimeErrorWithSourceLocation(BuildMessage(method, arguments, err), source), savedErrno(err)
8 {
9 }
10
11 std::string SyscallError::BuildMessage(const std::string& method, const std::string& arguments, int err)
12 {
13 std::stringstream str;
14
15 str << method << "(" << arguments << ") failed with errno=" << err << " (" << strerror(err) << ")";
16
17 return str.str();
18 }
19
20 int SyscallError::GetErrno() const
21 {
22 return savedErrno;
23 }