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

Side by Side Diff: sdk/lib/_internal/compiler/samples/leap/leap_server.dart

Issue 16123036: Clean up dart:io exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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
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 library leap_server; 5 library leap_server;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 class Conversation { 9 class Conversation {
10 HttpRequest request; 10 HttpRequest request;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 f.openRead().pipe(response).catchError(onError); 65 f.openRead().pipe(response).catchError(onError);
66 }); 66 });
67 } 67 }
68 68
69 static onRequest(HttpRequest request) { 69 static onRequest(HttpRequest request) {
70 new Conversation(request, request.response).handle(); 70 new Conversation(request, request.response).handle();
71 } 71 }
72 72
73 static onError(error) { 73 static onError(error) {
74 if (error is HttpParserException) { 74 if (error is HttpException) {
75 print('Error: ${error.message}'); 75 print('Error: ${error.message}');
76 } else { 76 } else {
77 print('Error: ${error}'); 77 print('Error: ${error}');
78 } 78 }
79 } 79 }
80 80
81 String htmlInfo(String title, String text) { 81 String htmlInfo(String title, String text) {
82 return """ 82 return """
83 <!DOCTYPE html> 83 <!DOCTYPE html>
84 <html lang='en'> 84 <html lang='en'>
(...skipping 23 matching lines...) Expand all
108 port = int.parse(arguments[2]); 108 port = int.parse(arguments[2]);
109 } 109 }
110 HttpServer.bind(host, port).then((HttpServer server) { 110 HttpServer.bind(host, port).then((HttpServer server) {
111 print('HTTP server started on http://$host:${server.port}/'); 111 print('HTTP server started on http://$host:${server.port}/');
112 server.listen(Conversation.onRequest, onError: Conversation.onError); 112 server.listen(Conversation.onRequest, onError: Conversation.onError);
113 }).catchError((e) { 113 }).catchError((e) {
114 print("HttpServer.bind error: $e"); 114 print("HttpServer.bind error: $e");
115 exit(1); 115 exit(1);
116 }); 116 });
117 } 117 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/source_file_provider.dart ('k') | sdk/lib/_internal/dartdoc/lib/dartdoc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698