Skip to content

Commit

Permalink
[CFE] Change error message on package uri error
Browse files Browse the repository at this point in the history
Bug: #59606
Change-Id: Id2737637f5074bc7ab4a1647fabe64a95a949218
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397760
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Jens Johansen <[email protected]>
  • Loading branch information
jensjoha authored and Commit Queue committed Nov 27, 2024
1 parent bd8b640 commit a2f0647
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/front_end/lib/src/base/uri_translator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class UriTranslator {
// https://github.com/dart-lang/package_config/issues/40 is fixed.
if (reportMessage) {
options.reportWithoutLocation(
templateInvalidPackageUri.withArguments(uri, '$e'), Severity.error);
templateInvalidPackageUri.withArguments(uri, "${e.message}"),
Severity.error);
}
return null;
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/front_end/testcases/regress/issue_59606.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import 'package:foobar1' as a;
import 'package:foobar%32' as b;
25 changes: 25 additions & 0 deletions pkg/front_end/testcases/regress/issue_59606.dart.strong.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Problems outside component:
//
// Error: Invalid package URI 'package:foobar1':
// Package URIs must start with the package name followed by a '/'.
//
// Error: Invalid package URI 'package:foobar2':
// Package URIs must start with the package name followed by a '/'.
//
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/issue_59606.dart:1:8: Error: Not found: 'package:foobar1'
// import 'package:foobar1' as a;
// ^
//
// pkg/front_end/testcases/regress/issue_59606.dart:2:8: Error: Not found: 'package:foobar2'
// import 'package:foobar%32' as b;
// ^
//
import self as self;

import "package:foobar1" as a;
import "package:foobar2" as b;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Problems outside component:
//
// Error: Invalid package URI 'package:foobar1':
// Package URIs must start with the package name followed by a '/'.
//
// Error: Invalid package URI 'package:foobar2':
// Package URIs must start with the package name followed by a '/'.
//
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/issue_59606.dart:1:8: Error: Not found: 'package:foobar1'
// import 'package:foobar1' as a;
// ^
//
// pkg/front_end/testcases/regress/issue_59606.dart:2:8: Error: Not found: 'package:foobar2'
// import 'package:foobar%32' as b;
// ^
//
import self as self;

import "package:foobar1" as a;
import "package:foobar2" as b;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Problems outside component:
//
// Error: Invalid package URI 'package:foobar1':
// Package URIs must start with the package name followed by a '/'.
//
// Error: Invalid package URI 'package:foobar2':
// Package URIs must start with the package name followed by a '/'.
//
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/issue_59606.dart:1:8: Error: Not found: 'package:foobar1'
// import 'package:foobar1' as a;
// ^
//
// pkg/front_end/testcases/regress/issue_59606.dart:2:8: Error: Not found: 'package:foobar2'
// import 'package:foobar%32' as b;
// ^
//
import self as self;

import "package:foobar1" as a;
import "package:foobar2" as b;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/regress/issue_59606.dart:1:8: Error: Not found: 'package:foobar1'
// import 'package:foobar1' as a;
// ^
//
// pkg/front_end/testcases/regress/issue_59606.dart:2:8: Error: Not found: 'package:foobar2'
// import 'package:foobar%32' as b;
// ^
//
import self as self;

import "package:foobar1" as a;
import "package:foobar2" as b;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'package:foobar1' as a;

import 'package:foobar%32' as b;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import 'package:foobar%32' as b;
import 'package:foobar1' as a;

0 comments on commit a2f0647

Please sign in to comment.