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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/pubspec.dart

Issue 632483002: Printing a useful error message if a version field is a num (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 | « no previous file | sdk/lib/_internal/pub_generated/lib/src/pubspec.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 pub.pubspec; 5 library pub.pubspec;
6 6
7 import 'package:path/path.dart' as path; 7 import 'package:path/path.dart' as path;
8 import 'package:pub_semver/pub_semver.dart'; 8 import 'package:pub_semver/pub_semver.dart';
9 import 'package:source_span/source_span.dart'; 9 import 'package:source_span/source_span.dart';
10 import 'package:yaml/yaml.dart'; 10 import 'package:yaml/yaml.dart';
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 Version get version { 67 Version get version {
68 if (_version != null) return _version; 68 if (_version != null) return _version;
69 69
70 var version = fields['version']; 70 var version = fields['version'];
71 if (version == null) { 71 if (version == null) {
72 _version = Version.none; 72 _version = Version.none;
73 return _version; 73 return _version;
74 } 74 }
75 75
76 var span = fields.nodes['version'].span; 76 var span = fields.nodes['version'].span;
77 if (version is num) {
78 _error('"version" field must be written in MAJOR.MINOR.PATCH[SUFFIX] forma t', span);
Bob Nystrom 2014/10/06 16:19:34 I think the all caps part might confuse users a bi
srawlins 2014/10/06 17:33:08 Love it! Done.
79 }
77 if (version is! String) { 80 if (version is! String) {
78 _error('"version" field must be a string.', span); 81 _error('"version" field must be a string.', span);
79 } 82 }
80 83
81 _version = _wrapFormatException('version number', span, 84 _version = _wrapFormatException('version number', span,
82 () => new Version.parse(version)); 85 () => new Version.parse(version));
83 return _version; 86 return _version;
84 } 87 }
85 Version _version; 88 Version _version;
86 89
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 implements ApplicationException { 582 implements ApplicationException {
580 PubspecException(String message, SourceSpan span) 583 PubspecException(String message, SourceSpan span)
581 : super(message, span); 584 : super(message, span);
582 } 585 }
583 586
584 /// Returns whether [uri] is a file URI. 587 /// Returns whether [uri] is a file URI.
585 /// 588 ///
586 /// This is slightly more complicated than just checking if the scheme is 589 /// This is slightly more complicated than just checking if the scheme is
587 /// 'file', since relative URIs also refer to the filesystem on the VM. 590 /// 'file', since relative URIs also refer to the filesystem on the VM.
588 bool _isFileUri(Uri uri) => uri.scheme == 'file' || uri.scheme == ''; 591 bool _isFileUri(Uri uri) => uri.scheme == 'file' || uri.scheme == '';
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/pub_generated/lib/src/pubspec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698