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 /// The main entrypoint for the pub command line application. | 5 /// The main entrypoint for the pub command line application. |
6 library pub; | 6 library pub; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:math'; | 10 import 'dart:math'; |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 // base Exception type so there's no easy way to know if it's available | 252 // base Exception type so there's no easy way to know if it's available |
253 // short of a giant pile of type tests for each known exception type. | 253 // short of a giant pile of type tests for each known exception type. |
254 // | 254 // |
255 // So just try it. If it throws, default to toString(). | 255 // So just try it. If it throws, default to toString(). |
256 message = error.message; | 256 message = error.message; |
257 } on NoSuchMethodError catch (_) { | 257 } on NoSuchMethodError catch (_) { |
258 message = error.toString(); | 258 message = error.toString(); |
259 } | 259 } |
260 | 260 |
261 log.error(message); | 261 log.error(message); |
262 if (globalOptions['trace'] && trace != null) { | 262 |
263 log.error(trace); | 263 if (trace != null) { |
| 264 if (globalOptions['trace'] || !isUserFacingException(error)) { |
| 265 log.error(trace); |
| 266 } else { |
| 267 log.fine(trace); |
| 268 } |
| 269 } |
| 270 |
| 271 if (globalOptions['trace']) { |
264 log.dumpTranscript(); | 272 log.dumpTranscript(); |
265 } else { | 273 } else if (!isUserFacingException(error)) { |
266 log.fine(trace); | 274 log.error(""" |
| 275 This is an unexpected error. Please run |
| 276 |
| 277 pub --trace ${new Options().arguments.map((arg) => "'$arg'").join(' ')} |
| 278 |
| 279 and include the results in a bug report on http://dartbug.com/new. |
| 280 """); |
267 } | 281 } |
268 | 282 |
269 exit(_chooseExitCode(error)); | 283 exit(_chooseExitCode(error)); |
270 } | 284 } |
271 | 285 |
272 new Future.sync(() { | 286 new Future.sync(() { |
273 if (requiresEntrypoint) { | 287 if (requiresEntrypoint) { |
274 // TODO(rnystrom): Will eventually need better logic to walk up | 288 // TODO(rnystrom): Will eventually need better logic to walk up |
275 // subdirectories until we hit one that looks package-like. For now, | 289 // subdirectories until we hit one that looks package-like. For now, |
276 // just assume the cwd is it. | 290 // just assume the cwd is it. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 if (exception is HttpException || exception is HttpParserException || | 339 if (exception is HttpException || exception is HttpParserException || |
326 exception is SocketIOException || exception is PubHttpException) { | 340 exception is SocketIOException || exception is PubHttpException) { |
327 return exit_codes.UNAVAILABLE; | 341 return exit_codes.UNAVAILABLE; |
328 } else if (exception is FormatException) { | 342 } else if (exception is FormatException) { |
329 return exit_codes.DATA; | 343 return exit_codes.DATA; |
330 } else { | 344 } else { |
331 return 1; | 345 return 1; |
332 } | 346 } |
333 } | 347 } |
334 } | 348 } |
OLD | NEW |