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

Side by Side Diff: recipes/dart_io/pkg_http/bin/handling_an_httprequest_error.dart

Issue 99333012: The first few short pkg:http examples (Closed) Base URL: https://github.com/dart-lang/cookbook.git@master
Patch Set: Created 7 years 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
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698