@@ -371,6 +371,20 @@ function showerror_nostdio(err, msg::AbstractString)
371
371
ccall (:jl_printf , Cint, (Ptr{Cvoid},Cstring), stderr_stream, " \n " )
372
372
end
373
373
374
+ stacktrace_expand_basepaths ():: Bool =
375
+ tryparse (Bool, get (ENV , " JULIA_STACKTRACE_EXPAND_BASEPATHS" , " false" )) === true
376
+ stacktrace_contract_userdir ():: Bool =
377
+ tryparse (Bool, get (ENV , " JULIA_STACKTRACE_CONTRACT_HOMEDIR" , " true" )) === true
378
+ stacktrace_linebreaks ():: Bool =
379
+ tryparse (Bool, get (ENV , " JULIA_STACKTRACE_LINEBREAKS" , " false" )) === true
380
+
381
+ function replaceuserpath (str:: String )
382
+ str = replace (str, homedir () => " ~" )
383
+ # seems to be necessary for some paths with small letter drive c:// etc
384
+ str = replace (str, lowercasefirst (homedir ()) => " ~" )
385
+ return str
386
+ end
387
+
374
388
function show_method_candidates (io:: IO , ex:: MethodError , @nospecialize kwargs= ())
375
389
is_arg_types = isa (ex. args, DataType)
376
390
arg_types = is_arg_types ? ex. args : typesof (ex. args... )
@@ -498,7 +512,12 @@ function show_method_candidates(io::IO, ex::MethodError, @nospecialize kwargs=()
498
512
end
499
513
print (iob, " )" )
500
514
show_method_params (iob0, tv)
501
- print (iob, " at " , method. file, " :" , method. line)
515
+ file, line = functionloc (method)
516
+ if file === nothing
517
+ file = string (method. file)
518
+ end
519
+ stacktrace_contract_userdir () && (file = replaceuserpath (file))
520
+ print (iob, " at " , file, " :" , line)
502
521
if ! isempty (kwargs):: Bool
503
522
unexpected = Symbol[]
504
523
if isempty (kwords) || ! (any (endswith (string (kword), " ..." ) for kword in kwords))
555
574
# replace `sf` as needed.
556
575
const update_stackframes_callback = Ref {Function} (identity)
557
576
558
- function replaceuserpath (str)
559
- str = replace (str, homedir () => " ~" )
560
- # seems to be necessary for some paths with small letter drive c:// etc
561
- str = replace (str, lowercasefirst (homedir ()) => " ~" )
562
- return str
563
- end
564
-
565
577
const STACKTRACE_MODULECOLORS = [:light_blue , :light_yellow ,
566
578
:light_magenta , :light_green , :light_cyan , :light_red ,
567
579
:blue , :yellow , :magenta , :green , :cyan , :red ]
568
- stacktrace_expand_basepaths ():: Bool =
569
- tryparse (Bool, get (ENV , " JULIA_STACKTRACE_EXPAND_BASEPATHS" , " false" )) === true
570
- stacktrace_contract_userdir ():: Bool =
571
- tryparse (Bool, get (ENV , " JULIA_STACKTRACE_CONTRACT_HOMEDIR" , " true" )) === true
572
- stacktrace_linebreaks ():: Bool =
573
- tryparse (Bool, get (ENV , " JULIA_STACKTRACE_LINEBREAKS" , " false" )) === true
574
580
575
581
function show_full_backtrace (io:: IO , trace:: Vector ; print_linebreaks:: Bool )
576
582
n = length (trace)
700
706
# Print a stack frame where the module color is set manually with `modulecolor`.
701
707
function print_stackframe (io, i, frame, n, digit_align_width, modulecolor)
702
708
file, line = string (frame. file), frame. line
709
+ file = updated_methodfile (file)
703
710
stacktrace_expand_basepaths () && (file = something (find_source_file (file), file))
704
711
stacktrace_contract_userdir () && (file = replaceuserpath (file))
705
712
0 commit comments