Skip to content

Commit 52f1d7f

Browse files
authored
Less confusing error message (#4789)
Pull request: #4789
1 parent 1331000 commit 52f1d7f

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

core/define/src/mill/define/Ctx.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import scala.annotation.{compileTimeOnly, implicitNotFound}
77
/**
88
* The contextual information provided to a [[mill.define.Module]] or [[mill.define.Task]]
99
*/
10-
@implicitNotFound("Modules and Tasks can only be defined within a mill Module")
10+
@implicitNotFound(
11+
"Modules and Tasks can only be defined within a mill Module (in `build.mill` or `package.mill` files)"
12+
)
1113
trait Ctx extends Ctx.Nested {
1214
def enclosing: String
1315

@@ -153,7 +155,7 @@ trait LowPriCtx {
153155
// as it is provided by the codegen. Defined for IDEs to think that one is available
154156
// and not show errors in build.mill/package.mill even though they can't see the codegen
155157
@compileTimeOnly(
156-
"Modules and Tasks can only be defined within a mill Module"
158+
"Modules and Tasks can only be defined within a mill Module (in `build.mill` or `package.mill` files)"
157159
)
158160
implicit def dummyInfo: Ctx = sys.error("implicit Ctx must be provided")
159161
}

integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object ModuleOutsideTopLevelModuleTests extends UtestIntegrationTestSuite {
1212
assert(!res.isSuccess)
1313
assert(
1414
res.err.contains(
15-
"Modules and Tasks can only be defined within a mill Module"
15+
"Modules and Tasks can only be defined within a mill Module (in `build.mill` or `package.mill` files)"
1616
)
1717
)
1818
assert(

integration/failure/no-modules-in-helper-file/src/NoModulesInHelperFileTests.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ object NoModulesInHelperFileTests extends UtestIntegrationTestSuite {
1111
val res = eval(("resolve", "_"))
1212
assert(res.isSuccess == false)
1313
assert(
14-
res.err.contains("Modules and Tasks can only be defined within a mill Module")
14+
res.err.contains(
15+
"Modules and Tasks can only be defined within a mill Module (in `build.mill` or `package.mill` files)"
16+
)
1517
)
1618
assert(res.err.contains("object foo extends Module"))
1719
}

0 commit comments

Comments
 (0)