Skip to content

Commit 6dec55f

Browse files
committed
improve invalid output error messages, fixes #106
1 parent d4bf6a9 commit 6dec55f

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

lib/src/asset/exceptions.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ class PackageNotFoundException implements Exception {
2424

2525
class InvalidOutputException implements Exception {
2626
final Asset asset;
27+
final String message;
2728

28-
InvalidOutputException(this.asset);
29+
InvalidOutputException(this.asset, this.message);
2930

3031
@override
31-
String toString() => 'InvalidOutputException: $asset\n'
32-
'Files may only be output in the root (application) package.';
32+
String toString() => 'InvalidOutputException: $asset\n$message';
3333
}
3434

3535
class InvalidInputException implements Exception {

lib/src/builder/build_step_impl.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ class BuildStepImpl implements BuildStep {
128128
/// [InvalidOutputException] or [UnexpectedOutputException] if it's not.
129129
void _checkOutput(Asset asset) {
130130
if (asset.id.package != _rootPackage) {
131-
throw new InvalidOutputException(asset);
131+
throw new InvalidOutputException(
132+
asset, 'Files may only be output in the root (application) package.');
132133
}
133134
if (!expectedOutputs.any((id) => id == asset.id)) {
134135
throw new UnexpectedOutputException(asset);

lib/src/generate/build_impl.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,12 @@ class BuildImpl {
517517
/// Validate [expectedOutputs].
518518
for (var output in expectedOutputs) {
519519
if (output.package != _packageGraph.root.name) {
520-
throw new InvalidOutputException(new Asset(output, ''));
520+
throw new InvalidOutputException(new Asset(output, ''),
521+
'Files may only be output in the root (application) package.');
521522
}
522523
if (_inputsByPackage[output.package]?.contains(output) == true) {
523-
throw new InvalidOutputException(new Asset(output, ''));
524+
throw new InvalidOutputException(new Asset(output, ''),
525+
'Cannot overwrite inputs.');
524526
}
525527
}
526528

0 commit comments

Comments
 (0)