Skip to content

Commit b1697a2

Browse files
authored
Use full error message string in CommandResolutionFailedException (#2870)
1 parent 16a6210 commit b1697a2

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/src/executable.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ Future<String> getExecutableForCommand(
334334
return p.relative(snapshotPath, from: root);
335335
}
336336
} on ApplicationException catch (e) {
337-
throw CommandResolutionFailedException(e.message);
337+
throw CommandResolutionFailedException(e.toString());
338338
}
339339
}
340340

test/embedding/get_executable_for_command_test.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,33 @@ Future<void> main() async {
6969
errorMessage: contains('Could not find file `bar${separator}m.dart`'));
7070
});
7171

72+
test('Error message when pubspec is broken', () async {
73+
await d.dir('foo', [
74+
d.pubspec({
75+
'name': 'broken name',
76+
}),
77+
]).create();
78+
79+
await d.dir(appPath, [
80+
d.pubspec({
81+
'name': 'myapp',
82+
'environment': {'sdk': '>=$_currentVersion <3.0.0'},
83+
'dependencies': {
84+
'foo': {
85+
'path': '../foo',
86+
},
87+
},
88+
}),
89+
]).create();
90+
final dir = d.path(appPath);
91+
await testGetExecutable('foo:app', dir,
92+
errorMessage: allOf(
93+
contains(
94+
'Error on line 1, column 9 of ${d.sandbox}${p.separator}foo${p.separator}pubspec.yaml: "name" field must be a valid Dart identifier.'),
95+
contains(
96+
'{"name":"broken name","environment":{"sdk":">=0.1.2 <1.0.0"}}')));
97+
});
98+
7299
test('Does `pub get` if there is a pubspec.yaml', () async {
73100
await d.dir(appPath, [
74101
d.pubspec({

0 commit comments

Comments
 (0)