OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 fasta.translate_uri; | 5 library fasta.translate_uri; |
6 | 6 |
7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
8 import 'dart:io' show FileSystemException; | |
9 | 8 |
10 import 'package:front_end/file_system.dart'; | 9 import 'package:front_end/file_system.dart'; |
11 import 'package:package_config/packages_file.dart' as packages_file show parse; | 10 import 'package:package_config/packages_file.dart' as packages_file show parse; |
12 | 11 |
13 import 'errors.dart' show inputError; | 12 import 'errors.dart' show inputError; |
14 | 13 |
15 class TranslateUri { | 14 class TranslateUri { |
16 final Map<String, Uri> packages; | 15 final Map<String, Uri> packages; |
17 final Map<String, Uri> dartLibraries; | 16 final Map<String, Uri> dartLibraries; |
18 | 17 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 "web_audio": | 93 "web_audio": |
95 sdk.resolve("lib/web_audio/dartium/web_audio_dartium.dart"), | 94 sdk.resolve("lib/web_audio/dartium/web_audio_dartium.dart"), |
96 "web_gl": sdk.resolve("lib/web_gl/dartium/web_gl_dartium.dart"), | 95 "web_gl": sdk.resolve("lib/web_gl/dartium/web_gl_dartium.dart"), |
97 "web_sql": sdk.resolve("lib/web_sql/dartium/web_sql_dartium.dart"), | 96 "web_sql": sdk.resolve("lib/web_sql/dartium/web_sql_dartium.dart"), |
98 }; | 97 }; |
99 } | 98 } |
100 uri ??= Uri.base.resolve(".packages"); | 99 uri ??= Uri.base.resolve(".packages"); |
101 | 100 |
102 List<int> bytes; | 101 List<int> bytes; |
103 try { | 102 try { |
104 FileSystemException; | |
105 bytes = await fileSystem.entityForUri(uri).readAsBytes(); | 103 bytes = await fileSystem.entityForUri(uri).readAsBytes(); |
106 } on FileSystemException catch (e) { | 104 } on FileSystemException catch (e) { |
107 String message = e.message; | 105 inputError(uri, -1, e.message); |
108 String osMessage = e.osError?.message; | |
109 if (osMessage != null && osMessage.isNotEmpty) { | |
110 message = osMessage; | |
111 } | |
112 inputError(uri, -1, message); | |
113 } | 106 } |
114 | 107 |
115 Map<String, Uri> packages = const <String, Uri>{}; | 108 Map<String, Uri> packages = const <String, Uri>{}; |
116 try { | 109 try { |
117 packages = packages_file.parse(bytes, uri); | 110 packages = packages_file.parse(bytes, uri); |
118 } on FormatException catch (e) { | 111 } on FormatException catch (e) { |
119 return inputError(uri, e.offset, e.message); | 112 return inputError(uri, e.offset, e.message); |
120 } | 113 } |
121 return new TranslateUri(packages, dartLibraries); | 114 return new TranslateUri(packages, dartLibraries); |
122 } | 115 } |
123 } | 116 } |
OLD | NEW |