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

Unified Diff: runtime/bin/socket.dart

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/socket.cc ('k') | runtime/bin/socket_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket.dart
diff --git a/runtime/bin/socket.dart b/runtime/bin/socket.dart
index ad48172bf596e8a03ec49c1e9a1a77480b198405..bb804716668ab00bb66240a3e852be820b5fdc03 100644
--- a/runtime/bin/socket.dart
+++ b/runtime/bin/socket.dart
@@ -18,7 +18,7 @@ interface ServerSocket default _ServerSocket {
/**
* The error handler gets called when a socket error occurs.
*/
- void set onError(void callback());
+ void set onError(void callback(Exception e));
/**
* Returns the port used by this socket.
@@ -34,8 +34,9 @@ interface ServerSocket default _ServerSocket {
interface Socket extends Hashable default _Socket {
/**
- * Constructs a new socket and connects it to the given host on the given
- * port.
+ * Constructs a new socket and initiate connecting it to the given
+ * host on the given port. The returned socket is not yet connected
+ * but ready for registration of callbacks.
*/
Socket(String host, int port);
@@ -88,7 +89,7 @@ interface Socket extends Hashable default _Socket {
/**
* The error handler gets called when a socket error occurs.
*/
- void set onError(void callback());
+ void set onError(void callback(Exception e));
/**
* Returns input stream to the socket.
@@ -122,7 +123,21 @@ interface Socket extends Hashable default _Socket {
class SocketIOException implements Exception {
- const SocketIOException([String this.message = ""]);
- String toString() => "SocketIOException: $message";
+ const SocketIOException([String this.message = "",
+ OSError this.osError = null]);
+ String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.add("SocketIOException");
+ if (!message.isEmpty()) {
+ sb.add(": $message");
+ if (osError != null) {
+ sb.add(" ($osError)");
+ }
+ } else if (osError != null) {
+ sb.add(": osError");
+ }
+ return sb.toString();
+ }
final String message;
+ final OSError osError;
}
« no previous file with comments | « runtime/bin/socket.cc ('k') | runtime/bin/socket_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698