Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: runtime/bin/utils.h

Issue 9699017: Start better error reporting for sockets (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed bug Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/socket_win.cc ('k') | runtime/bin/utils_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef BIN_UTILS_H_ 5 #ifndef BIN_UTILS_H_
6 #define BIN_UTILS_H_ 6 #define BIN_UTILS_H_
7 7
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 10
11 #include "include/dart_api.h" 11 #include "include/dart_api.h"
12 #include "platform/globals.h" 12 #include "platform/globals.h"
13 13
14 class OSError { 14 class OSError {
15 public: 15 public:
16 enum SubSystem {
17 kSystem,
18 kGetAddressInfo,
19 kUnknown = -1
20 };
21
16 OSError(); 22 OSError();
17 OSError(int code, char* message) { 23 OSError(int code, const char* message, SubSystem sub_system) {
24 sub_system_ = sub_system;
18 code_ = code; 25 code_ = code;
26 message_ = NULL; // SetMessage will free existing message.
19 SetMessage(message); 27 SetMessage(message);
20 } 28 }
21 virtual ~OSError() { free(message_); } 29 virtual ~OSError() { free(message_); }
22 30
31 SubSystem sub_system() { return sub_system_; }
32 void set_sub_system(SubSystem sub_system) { sub_system_ = sub_system; }
23 int code() { return code_; } 33 int code() { return code_; }
24 void set_code(int code) { code_ = code; } 34 void set_code(int code) { code_ = code; }
25 char* message() { return message_; } 35 char* message() { return message_; }
26 void SetMessage(char* message) { 36 void SetMessage(const char* message) {
27 free(message_); 37 free(message_);
28 if (message == NULL) { 38 if (message == NULL) {
29 message_ = NULL; 39 message_ = NULL;
30 } else { 40 } else {
31 message_ = strdup(message); 41 message_ = strdup(message);
32 } 42 }
33 } 43 }
34 44
35 private: 45 private:
46 SubSystem sub_system_;
36 int code_; 47 int code_;
37 char* message_; 48 char* message_;
38 49
39 DISALLOW_COPY_AND_ASSIGN(OSError); 50 DISALLOW_COPY_AND_ASSIGN(OSError);
40 }; 51 };
41 52
42 #endif // BIN_UTILS_H_ 53 #endif // BIN_UTILS_H_
OLDNEW
« no previous file with comments | « runtime/bin/socket_win.cc ('k') | runtime/bin/utils_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698