Skip to content

Commit

Permalink
Add current stylesheet to loadedUrls when throwing parsing error (#1991)
Browse files Browse the repository at this point in the history
Co-authored-by: Natalie Weizenbaum <nweiz@google.com>
  • Loading branch information
ntkme and nex3 authored Jun 9, 2023
1 parent 645e48f commit 760fa2e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.63.4

### Embedded Sass

* Properly include the root stylesheet's URL in the set of loaded URLs when it
fails to parse.

## 1.63.3

### JavaScript API
Expand Down
25 changes: 16 additions & 9 deletions lib/src/ast/sass/statement/stylesheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,22 @@ class Stylesheet extends ParentStatement<List<Statement>> {
/// Throws a [SassFormatException] if parsing fails.
factory Stylesheet.parse(String contents, Syntax syntax,
{Object? url, Logger? logger}) {
switch (syntax) {
case Syntax.sass:
return Stylesheet.parseSass(contents, url: url, logger: logger);
case Syntax.scss:
return Stylesheet.parseScss(contents, url: url, logger: logger);
case Syntax.css:
return Stylesheet.parseCss(contents, url: url, logger: logger);
default:
throw ArgumentError("Unknown syntax $syntax.");
try {
switch (syntax) {
case Syntax.sass:
return Stylesheet.parseSass(contents, url: url, logger: logger);
case Syntax.scss:
return Stylesheet.parseScss(contents, url: url, logger: logger);
case Syntax.css:
return Stylesheet.parseCss(contents, url: url, logger: logger);
default:
throw ArgumentError("Unknown syntax $syntax.");
}
} on SassException catch (error) {
var url = error.span.sourceUrl;
if (url == null || url.toString() == 'stdin') rethrow;

throw error.withLoadedUrls(Set.unmodifiable({url}));
}
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass
version: 1.63.3
version: 1.63.4-dev
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down

0 comments on commit 760fa2e

Please sign in to comment.