Created
June 10, 2012 14:46
-
-
Save vadimtsushko/2906010 to your computer and use it in GitHub Desktop.
ransform block silently swallow exeptions. When it combines with open socket - script seems to be hanged up. sdk revision 8478
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import("dart:io"); | |
Future getFuture() { | |
var completer = new Completer(); | |
new Timer(100,(timer) => completer.complete(true)); | |
return completer.future; | |
} | |
Future openSocket() { | |
var completer = new Completer(); | |
Socket socket = new Socket('www.dartlang.org', 80); | |
if (socket is! Socket) { | |
completer.completeException(new Exception( "can't get send socket")); | |
} else { | |
socket.onError = (e) { | |
print("connect exception ${e}"); | |
completer.completeException(e); | |
}; | |
socket.onConnect = () { | |
completer.complete(socket); | |
}; | |
} | |
return completer.future; | |
} | |
void main() { | |
openSocket().chain((_) { | |
print("Before exception in chain block"); | |
throw 'Error in chain block'; | |
print("After exception in chain block"); | |
return getFuture(); | |
}).then((_) { | |
print("Before exception in then block"); | |
throw 'Error in then block'; | |
print("After exception in then block"); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment