Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up a few error messages #781

Merged
merged 5 commits into from Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,12 @@
## 1.22.9

* Include argument names when reporting range errors and selector parse errors.

* Avoid double `Error:` headers when reporting selector parse errors.

* Clarify the error message when the wrong number of positional arguments are
passed along with a named argument.

## 1.22.8

### JavaScript API
Expand Down
1 change: 1 addition & 0 deletions lib/src/ast/sass/argument_declaration.dart
Expand Up @@ -81,6 +81,7 @@ class ArgumentDeclaration implements SassNode {

if (positional > arguments.length) {
throw SassScriptException("Only ${arguments.length} "
"${names.isEmpty ? '' : 'positional '}"
"${pluralize('argument', arguments.length)} allowed, but "
"${positional} ${pluralize('was', positional, plural: 'were')} "
"passed.");
Expand Down
6 changes: 3 additions & 3 deletions lib/src/value.dart
Expand Up @@ -120,7 +120,7 @@ abstract class Value implements ext.Value {
} on SassFormatException catch (error) {
// TODO(nweiz): colorize this if we're running in an environment where
// that works.
throw _exception(error.toString());
throw _exception(error.toString().replaceFirst("Error: ", ""), name);
}
}

Expand All @@ -140,7 +140,7 @@ abstract class Value implements ext.Value {
} on SassFormatException catch (error) {
// TODO(nweiz): colorize this if we're running in an environment where
// that works.
throw _exception(error.toString());
throw _exception(error.toString().replaceFirst("Error: ", ""), name);
}
}

Expand All @@ -161,7 +161,7 @@ abstract class Value implements ext.Value {
} on SassFormatException catch (error) {
// TODO(nweiz): colorize this if we're running in an environment where
// that works.
throw _exception(error.toString());
throw _exception(error.toString().replaceFirst("Error: ", ""), name);
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/src/value/number.dart
Expand Up @@ -209,7 +209,8 @@ class SassNumber extends Value implements ext.SassNumber {
var result = fuzzyCheckRange(value, min, max);
if (result != null) return result;
throw _exception(
"Expected $this to be within $min$unitString and $max$unitString.");
"Expected $this to be within $min$unitString and $max$unitString.",
name);
}

bool hasUnit(String unit) =>
Expand Down
2 changes: 1 addition & 1 deletion lib/src/visitor/serialize.dart
Expand Up @@ -562,7 +562,7 @@ class _SerializeVisitor
_buffer.writeCharCode($lbracket);
} else if (value.asList.isEmpty) {
if (!_inspect) {
throw SassScriptException("() isn't a valid CSS value");
throw SassScriptException("() isn't a valid CSS value.");
}
_buffer.write("()");
return;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,5 +1,5 @@
name: sass
version: 1.22.8
version: 1.22.9-dev
description: A Sass implementation in Dart.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/sass/dart-sass
Expand Down