Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 import 'dart:io' show SocketException; | |
| 2 import 'package:http/http.dart' as http; | |
| 3 | |
| 4 handleSuccess(http.Response response) { | |
| 5 print('something went wrong'); | |
| 6 print(response.body); | |
| 7 } | |
| 8 | |
| 9 handleFailure(SocketException e) { | |
|
Anders Johnsen
2013/12/06 11:53:28
Don't expect SocketException. In theory, it could
shailentuli
2013/12/06 18:16:29
Done.
| |
| 10 print(e.message); | |
| 11 print('A ${e.runtimeType} was raised'); | |
| 12 } | |
| 13 | |
| 14 void main() { | |
| 15 http.get("http://some_bogus_website.org") | |
| 16 .then(handleSuccess) | |
| 17 .catchError(handleFailure); | |
| 18 } | |
| OLD | NEW |