OLD | NEW |
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 pub.source.hosted; | 5 library pub.source.hosted; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
9 import 'dart:json' as json; | 9 import 'dart:json' as json; |
10 | 10 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 error.response.statusCode == 404) { | 160 error.response.statusCode == 404) { |
161 fail('Could not find package "$package" at $url.'); | 161 fail('Could not find package "$package" at $url.'); |
162 } | 162 } |
163 | 163 |
164 if (error is TimeoutException) { | 164 if (error is TimeoutException) { |
165 fail('Timed out trying to find package "$package" at $url.'); | 165 fail('Timed out trying to find package "$package" at $url.'); |
166 } | 166 } |
167 | 167 |
168 if (error is io.SocketException) { | 168 if (error is io.SocketException) { |
169 fail('Got socket error trying to find package "$package" at $url.\n' | 169 fail('Got socket error trying to find package "$package" at $url.\n' |
170 '${error.osError}'); | 170 '$error'); |
171 } | 171 } |
172 | 172 |
173 // Otherwise re-throw the original exception. | 173 // Otherwise re-throw the original exception. |
174 throw error; | 174 throw error; |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 /// This is the modified hosted source used when pub install or update are run | 178 /// This is the modified hosted source used when pub install or update are run |
179 /// with "--offline". This uses the system cache to get the list of available | 179 /// with "--offline". This uses the system cache to get the list of available |
180 /// packages and does no network access. | 180 /// packages and does no network access. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 var name = description["name"]; | 262 var name = description["name"]; |
263 if (name is! String) { | 263 if (name is! String) { |
264 throw new FormatException("The 'name' key must have a string value."); | 264 throw new FormatException("The 'name' key must have a string value."); |
265 } | 265 } |
266 | 266 |
267 var url = description["url"]; | 267 var url = description["url"]; |
268 if (url == null) url = HostedSource.defaultUrl; | 268 if (url == null) url = HostedSource.defaultUrl; |
269 | 269 |
270 return new Pair<String, String>(name, url); | 270 return new Pair<String, String>(name, url); |
271 } | 271 } |
OLD | NEW |