Skip to content

Commit 53f452a

Browse files
authored
Better error message for task.scope (#54180)
Fixes #54178
1 parent 435ba8f commit 53f452a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

base/task.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ end
179179
# TODO: this field name should be deprecated in 2.0
180180
return t._isexception ? t.result : nothing
181181
elseif field === :scope
182-
error("Querying `scope` is disallowed. Use `current_scope` instead.")
182+
error("""
183+
Querying a Task's `scope` field is disallowed.
184+
The private `Core.current_scope()` function is better, though still an implementation detail.""")
183185
else
184186
return getfield(t, field)
185187
end

test/channels.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ end
642642
@testset "Task properties" begin
643643
f() = rand(2,2)
644644
t = Task(f)
645-
@test_throws ErrorException("Querying `scope` is disallowed. Use `current_scope` instead.") t.scope
645+
message = "Querying a Task's `scope` field is disallowed.\nThe private `Core.current_scope()` function is better, though still an implementation detail."
646+
@test_throws ErrorException(message) t.scope
646647
@test t.state == :runnable
647648
end

0 commit comments

Comments
 (0)