Index: runtime/bin/utils_macos.cc |
diff --git a/runtime/bin/utils_macos.cc b/runtime/bin/utils_macos.cc |
index 0b4a69fe35bf6d8295046b8f8c963c1d234cc8ad..f364e475700fc02c3e01b21471720b03858b6afb 100644 |
--- a/runtime/bin/utils_macos.cc |
+++ b/runtime/bin/utils_macos.cc |
@@ -3,11 +3,26 @@ |
// BSD-style license that can be found in the LICENSE file. |
#include <errno.h> |
+#include <netdb.h> |
#include "bin/utils.h" |
+#include "platform/assert.h" |
OSError::OSError() : sub_system_(kSystem), code_(0), message_(NULL) { |
set_sub_system(kSystem); |
set_code(errno); |
SetMessage(strerror(errno)); |
} |
+ |
+ |
+void OSError::SetCodeAndMessage(SubSystem sub_system, int code) { |
+ set_sub_system(sub_system); |
+ set_code(code); |
+ if (sub_system == kSystem) { |
+ SetMessage(strerror(code)); |
+ } else if (sub_system == kGetAddressInfo) { |
+ SetMessage(gai_strerror(code)); |
+ } else { |
+ UNREACHABLE(); |
+ } |
+} |