We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a1266e0 commit 695c3acCopy full SHA for 695c3ac
base/errorshow.jl
@@ -85,11 +85,18 @@ function showerror(io::IO, ex, bt; backtrace=true)
85
end
86
87
function showerror(io::IO, ex::LoadError, bt; backtrace=true)
88
- print(io, "Error while loading expression starting at ", ex.file, ":", ex.line)
+ print(io, "LoadError: ")
89
+ showerror(io, ex.error, bt, backtrace=backtrace)
90
+ print(io, "\nin expression starting at $(ex.file):$(ex.line)")
91
92
showerror(io::IO, ex::LoadError) = showerror(io, ex, [])
93
-showerror(io::IO, ex::InitError) = print(io, "InitError during initialization of module ", ex.mod)
94
+function showerror(io::IO, ex::InitError, bt; backtrace=true)
95
+ print(io, "InitError: ")
96
97
+ print(io, "\nduring initialization of module ", ex.mod)
98
+end
99
+showerror(io::IO, ex::InitError) = showerror(io, ex, [])
100
101
function showerror(io::IO, ex::DomainError)
102
if isa(ex.val, AbstractArray)
src/ast.c
@@ -892,8 +892,8 @@ jl_value_t *jl_parse_eval_all(const char *fname,
892
if (jl_loaderror_type == NULL)
893
jl_rethrow();
894
else
895
- jl_throw(jl_new_struct(jl_loaderror_type, form, result,
896
- jl_current_exception()));
+ jl_rethrow_other(jl_new_struct(jl_loaderror_type, form, result,
+ jl_current_exception()));
897
}
898
JL_GC_POP();
899
return result;
@@ -1050,8 +1050,8 @@ static jl_value_t *jl_invoke_julia_macro(jl_array_t *args, jl_module_t *inmodule
1050
1051
margs[0] = jl_cstr_to_string("<macrocall>");
1052
margs[1] = jl_fieldref(lno, 0); // extract and allocate line number
1053
- jl_throw(jl_new_struct(jl_loaderror_type, margs[0], margs[1],
1054
+ jl_rethrow_other(jl_new_struct(jl_loaderror_type, margs[0], margs[1],
1055
1056
1057
ptls->world_age = last_age;
src/toplevel.c
@@ -79,8 +79,8 @@ void jl_module_run_initializer(jl_module_t *m)
79
80
81
else {
82
- jl_throw(jl_new_struct(jl_initerror_type, m->name,
83
+ jl_rethrow_other(jl_new_struct(jl_initerror_type, m->name,
84
test/backtrace.jl
@@ -199,7 +199,7 @@ let trace = try
199
200
""", "a_filename")
201
catch
202
- stacktrace(Base.catch_stack()[end-1][2]) # Ignore LoadError
+ stacktrace(catch_backtrace())
203
204
@test trace[1].func == Symbol("top-level scope")
205
@test trace[1].file == :a_filename
@@ -213,7 +213,7 @@ let trace = try
213
214
215
216
217
218
219
test/errorshow.jl
@@ -156,16 +156,15 @@ end
156
macro except_strbt(expr, err_type)
157
errmsg = "expected failure, but no exception thrown for $expr"
158
return quote
159
- let err = nothing, bt = nothing
+ let err = nothing
160
try
161
$(esc(expr))
162
catch err
163
- bt = catch_backtrace()
164
165
err === nothing && error($errmsg)
166
@test typeof(err) === $(esc(err_type))
167
buf = IOBuffer()
168
- showerror(buf, err, bt)
+ showerror(buf, err, catch_backtrace())
169
String(take!(buf))
170
171
@@ -555,12 +554,3 @@ let buf = IOBuffer()
555
554
Base.show_method_candidates(buf, Base.MethodError(sin, Tuple{NoMethodsDefinedHere}))
556
@test length(take!(buf)) !== 0
557
558
-
559
-@testset "Nested errors" begin
560
- # LoadError and InitError used to print the nested exception.
561
- # This is now dealt with via the exception stack so these print very simply:
562
- @test sprint(Base.showerror, LoadError("somefile.jl", 10, ErrorException("retained for backward compat"))) ==
563
- "Error while loading expression starting at somefile.jl:10"
564
- @test sprint(Base.showerror, InitError(:some_module, ErrorException("retained for backward compat"))) ==
565
- "InitError during initialization of module some_module"
566
-end
test/precompile.jl
@@ -371,7 +371,7 @@ try
371
error("break me")
372
373
""")
374
- @test_warn r"ERROR: Error while loading expression starting at.*FooBar2.*caused by.*break me"s try
+ @test_warn "ERROR: LoadError: break me\nStacktrace:\n [1] error" try
375
Base.require(Main, :FooBar2)
376
error("\"LoadError: break me\" test failed")
377
catch exc
0 commit comments