Skip to content

Commit ad16270

Browse files
nsicchaclaude
andcommitted
Simplify PropertyComputationError display: remove noisy filtered stacktrace
- Remove _filter_bt, _format_frame, _cause_backtrace (fragile, over-engineered) - Remove "Stacktrace (user code):" section — let Julia's exception chaining provide the full backtrace instead - Add try/catch safety wrapper in 3-arg showerror - Accept kwargs... for Julia's backtrace= kwarg Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 926da6d commit ad16270

1 file changed

Lines changed: 10 additions & 40 deletions

File tree

src/DynamicObjects.jl

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -998,16 +998,6 @@ unwrap_error(e) = e
998998

999999
# Extract the exception from cause (which may be a (exception, backtrace) tuple)
10001000
_cause_error(e::PropertyComputationError) = e.cause isa Tuple ? first(e.cause) : e.cause
1001-
_cause_backtrace(e::PropertyComputationError) = e.cause isa Tuple ? last(e.cause) : []
1002-
1003-
_filter_bt(bt) = filter(bt) do frame
1004-
file = string(frame.file)
1005-
!any(p -> occursin(p, file), (
1006-
"DynamicObjects.jl/src", "HTMXObjects.jl/src",
1007-
"/Oxygen/", "/HTTP/", "task.jl", "lock.jl",
1008-
"essentials.jl", "dict.jl",
1009-
))
1010-
end
10111001

10121002
function _format_property_key(name, indices, kwargs)
10131003
s = string(name)
@@ -1019,41 +1009,21 @@ function _format_property_key(name, indices, kwargs)
10191009
isempty(parts) ? s : s * "[" * join(parts, ", ") * "]"
10201010
end
10211011

1022-
function _format_frame(frame)
1023-
if frame.linfo isa Core.MethodInstance
1024-
try
1025-
sig = frame.linfo.specTypes
1026-
params = fieldtypes(sig)
1027-
fname = string(frame.func)
1028-
arg_strs = ["::$(p)" for p in params[2:end]]
1029-
return fname * "(" * join(arg_strs, ", ") * ")"
1030-
catch
1031-
end
1032-
end
1033-
return string(frame.func)
1034-
end
1035-
10361012
function Base.showerror(io::IO, e::PropertyComputationError)
10371013
key = _format_property_key(e.property, e.indices, e.kwargs)
1038-
root = unwrap_error(e)
10391014
print(io, "PropertyComputationError: computing `$key` on $(e.type_name)\n")
10401015
print(io, " Caused by: ")
1041-
showerror(io, root)
1042-
# Show filtered backtrace from the original throw site
1043-
orig_bt = _cause_backtrace(e)
1044-
if !isempty(orig_bt)
1045-
frames = Base.stacktrace(orig_bt)
1046-
filtered = _filter_bt(frames)
1047-
if !isempty(filtered)
1048-
println(io, "\n\n Stacktrace (user code):")
1049-
for (i, frame) in enumerate(filtered)
1050-
println(io, " [$i] $(_format_frame(frame)) at $(frame.file):$(frame.line)")
1051-
end
1052-
end
1053-
end
1016+
showerror(io, unwrap_error(e))
10541017
end
10551018

1056-
# 3-arg method: suppress Oxygen's backtrace since we show our own filtered one above
1057-
Base.showerror(io::IO, e::PropertyComputationError, ::Any) = showerror(io, e)
1019+
function Base.showerror(io::IO, e::PropertyComputationError, bt; kwargs...)
1020+
try
1021+
showerror(io, e)
1022+
catch internal_err
1023+
print(io, "PropertyComputationError (display failed: ")
1024+
showerror(io, internal_err)
1025+
print(io, ")")
1026+
end
1027+
end
10581028

10591029
end

0 commit comments

Comments
 (0)