diff --git a/src/evaluation/MacroAnalysis.jl b/src/evaluation/MacroAnalysis.jl index cd7a6e2352..44e9e96936 100644 --- a/src/evaluation/MacroAnalysis.jl +++ b/src/evaluation/MacroAnalysis.jl @@ -84,7 +84,7 @@ function resolve_topology( sn = (session, notebook) function macroexpand_cell(cell) - try_macroexpand(module_name::Symbol=Symbol("")) = begin + function try_macroexpand(module_name::Symbol=Symbol("")) success, result = macroexpand_in_workspace(sn, unresolved_topology.codes[cell].parsedcode, cell.cell_id, module_name) if success Success(result) diff --git a/src/evaluation/WorkspaceManager.jl b/src/evaluation/WorkspaceManager.jl index 3308fbf7e8..dfa29486d9 100644 --- a/src/evaluation/WorkspaceManager.jl +++ b/src/evaluation/WorkspaceManager.jl @@ -523,8 +523,10 @@ function macroexpand_in_workspace(session_notebook::SN, macrocall, cell_id, modu # We have to be careful here, for example a thrown `MethodError()` will contain the called method and arguments. # which normally would be very useful for debugging, but we can't serialize it! # So we make sure we only serialize the exception we know about, and string-ify the others. - if (error isa LoadError && error.error isa UndefVarError) || error isa UndefVarError - (false, error) + if error isa UndefVarError + (false, UndefVarError(error.var)) + elseif error isa LoadError && error.error isa UndefVarError + (false, UndefVarError(error.error.var)) else (false, ErrorException(sprint(showerror, error))) end