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

Side by Side Diff: dart/pkg/compiler/lib/src/source_file_provider.dart

Issue 841653004: Recover from read errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r42871 Created 5 years, 11 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
« no previous file with comments | « dart/pkg/compiler/lib/src/script.dart ('k') | dart/pkg/compiler/lib/src/warnings.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 source_file_provider; 5 library source_file_provider;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:math' as math; 10 import 'dart:math' as math;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 throw new ArgumentError("Unknown scheme in uri '$resourceUri'"); 46 throw new ArgumentError("Unknown scheme in uri '$resourceUri'");
47 } 47 }
48 } 48 }
49 49
50 Future<List<int>> _readFromFile(Uri resourceUri) { 50 Future<List<int>> _readFromFile(Uri resourceUri) {
51 assert(resourceUri.scheme == 'file'); 51 assert(resourceUri.scheme == 'file');
52 List<int> source; 52 List<int> source;
53 try { 53 try {
54 source = readAll(resourceUri.toFilePath()); 54 source = readAll(resourceUri.toFilePath());
55 } on FileSystemException catch (ex) { 55 } on FileSystemException catch (ex) {
56 OSError ose = ex.osError;
57 String detail = (ose != null && ose.message != null)
58 ? ' (${ose.message})'
59 : '';
56 return new Future.error( 60 return new Future.error(
57 "Error reading '${relativize(cwd, resourceUri, isWindows)}' " 61 "Error reading '${relativize(cwd, resourceUri, isWindows)}'"
58 "(${ex.osError})"); 62 "$detail");
59 } 63 }
60 dartCharactersRead += source.length; 64 dartCharactersRead += source.length;
61 sourceFiles[resourceUri.toString()] = 65 sourceFiles[resourceUri.toString()] =
62 new CachingUtf8BytesSourceFile(relativizeUri(resourceUri), source); 66 new CachingUtf8BytesSourceFile(relativizeUri(resourceUri), source);
63 return new Future.value(source); 67 return new Future.value(source);
64 } 68 }
65 69
66 Future<List<int>> _readFromHttp(Uri resourceUri) { 70 Future<List<int>> _readFromHttp(Uri resourceUri) {
67 assert(resourceUri.scheme == 'http'); 71 assert(resourceUri.scheme == 'http');
68 HttpClient client = new HttpClient(); 72 HttpClient client = new HttpClient();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 color = (x) => x; 200 color = (x) => x;
197 } 201 }
198 if (uri == null) { 202 if (uri == null) {
199 print('${color(message)}'); 203 print('${color(message)}');
200 } else { 204 } else {
201 SourceFile file = provider.sourceFiles[uri.toString()]; 205 SourceFile file = provider.sourceFiles[uri.toString()];
202 if (file != null) { 206 if (file != null) {
203 print(file.getLocationMessage( 207 print(file.getLocationMessage(
204 color(message), begin, end, colorize: color)); 208 color(message), begin, end, colorize: color));
205 } else { 209 } else {
206 print('${provider.relativizeUri(uri)}@$begin+${end - begin}:' 210 String position = end - begin > 0 ? '@$begin+${end - begin}' : '';
207 ' [$kind] ${color(message)}'); 211 print('${provider.relativizeUri(uri)}$position:\n'
212 '${color(message)}');
208 } 213 }
209 } 214 }
210 if (fatal && ++fatalCount >= throwOnErrorCount && throwOnError) { 215 if (fatal && ++fatalCount >= throwOnErrorCount && throwOnError) {
211 isAborting = true; 216 isAborting = true;
212 throw new AbortLeg(message); 217 throw new AbortLeg(message);
213 } 218 }
214 } 219 }
215 220
216 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { 221 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) {
217 return diagnosticHandler(uri, begin, end, message, kind); 222 return diagnosticHandler(uri, begin, end, message, kind);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 var onAdd, onClose; 323 var onAdd, onClose;
319 324
320 EventSinkWrapper(this.onAdd, this.onClose); 325 EventSinkWrapper(this.onAdd, this.onClose);
321 326
322 void add(String data) => onAdd(data); 327 void add(String data) => onAdd(data);
323 328
324 void addError(error, [StackTrace stackTrace]) => throw error; 329 void addError(error, [StackTrace stackTrace]) => throw error;
325 330
326 void close() => onClose(); 331 void close() => onClose();
327 } 332 }
OLDNEW
« no previous file with comments | « dart/pkg/compiler/lib/src/script.dart ('k') | dart/pkg/compiler/lib/src/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698