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

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

Issue 1291283006: dart2js: fail gracefully with invalid package config (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/diagnostics/messages.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) 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 leg_apiimpl; 5 library leg_apiimpl;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 import 'package:package_config/packages.dart'; 10 import 'package:package_config/packages.dart';
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // Use "non-file" packages because the file version requires a [Directory] 387 // Use "non-file" packages because the file version requires a [Directory]
388 // and we can't depend on 'dart:io' classes. 388 // and we can't depend on 'dart:io' classes.
389 packages = new NonFilePackagesDirectoryPackages(packageRoot); 389 packages = new NonFilePackagesDirectoryPackages(packageRoot);
390 } else if (packageConfig != null) { 390 } else if (packageConfig != null) {
391 return callUserProvider(packageConfig).then((packageConfigContents) { 391 return callUserProvider(packageConfig).then((packageConfigContents) {
392 if (packageConfigContents is String) { 392 if (packageConfigContents is String) {
393 packageConfigContents = UTF8.encode(packageConfigContents); 393 packageConfigContents = UTF8.encode(packageConfigContents);
394 } 394 }
395 // The input provider may put a trailing 0 byte when it reads a source 395 // The input provider may put a trailing 0 byte when it reads a source
396 // file, which confuses the package config parser. 396 // file, which confuses the package config parser.
397 if (packageConfigContents.length > 0 397 if (packageConfigContents.length > 0 &&
398 && packageConfigContents.last == 0) { 398 packageConfigContents.last == 0) {
399 packageConfigContents = packageConfigContents.sublist( 399 packageConfigContents = packageConfigContents.sublist(
400 0, packageConfigContents.length - 1); 400 0, packageConfigContents.length - 1);
401 } 401 }
402 packages = 402 try {
403 new MapPackages(pkgs.parse(packageConfigContents, packageConfig)); 403 packages =
404 new MapPackages(pkgs.parse(packageConfigContents, packageConfig));
405 } on FormatException catch (e) {
Siggi Cherem (dart-lang) 2015/08/19 22:39:39 since the error messages are the same, do we actua
Harry Terkelsen 2015/08/19 22:56:30 Done.
406 reportError(NO_LOCATION_SPANNABLE, MessageKind.INVALID_PACKAGE_CONFIG,
Siggi Cherem (dart-lang) 2015/08/19 22:39:39 not a big priority, but it would be interesting to
Harry Terkelsen 2015/08/19 22:56:30 Filed a FR with package_config: https://github.com
407 {'uri': packageConfig, 'exception': e});
408 packages = Packages.noPackages;
409 }
410 }).catchError((error) {
411 reportError(NO_LOCATION_SPANNABLE, MessageKind.INVALID_PACKAGE_CONFIG,
412 {'uri': packageConfig, 'exception': error});
Siggi Cherem (dart-lang) 2015/08/19 22:39:39 also add `packages = Packages.noPackages`?
Harry Terkelsen 2015/08/19 22:56:30 Done.
404 }); 413 });
405 } else { 414 } else {
406 if (packagesDiscoveryProvider == null) { 415 if (packagesDiscoveryProvider == null) {
407 packages = Packages.noPackages; 416 packages = Packages.noPackages;
408 } else { 417 } else {
409 return callUserPackagesDiscovery(uri).then((p) { 418 return callUserPackagesDiscovery(uri).then((p) {
410 packages = p; 419 packages = p;
411 }); 420 });
412 } 421 }
413 } 422 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 print('$message: ${tryToString(exception)}'); 507 print('$message: ${tryToString(exception)}');
499 print(tryToString(stackTrace)); 508 print(tryToString(stackTrace));
500 } 509 }
501 510
502 fromEnvironment(String name) => environment[name]; 511 fromEnvironment(String name) => environment[name];
503 512
504 LibraryInfo lookupLibraryInfo(String libraryName) { 513 LibraryInfo lookupLibraryInfo(String libraryName) {
505 return library_info.LIBRARIES[libraryName]; 514 return library_info.LIBRARIES[libraryName];
506 } 515 }
507 } 516 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/diagnostics/messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698