1+
2+
3+ function Base. showerror (io:: IO , nw:: GracefulPkg.NothingWorked )
4+ printstyled (io, " GracefulPkg.NothingWorked: The task failed, and no strategies from GracefulPkg could fix it...\n " ; bold= true )
5+
6+ report = nw. report
7+
8+ show (io, MIME " text/plain" (), report)
9+ end
10+
11+ function action_text_not_empty (action:: Strategy )
12+ s = action_text (action)
13+ isempty (s) ? " Doing nothing" : s
14+ end
15+
16+ function Base. show (io:: IO , :: MIME"text/plain" , report:: GracefulPkg.GraceReport )
17+ reps = report. strategy_reports
18+
19+ printstyled (io, " === BEGIN GRACEFULPKG REPORT ===\n " ; color= :light_black )
20+
21+ if length (reps) == 1 && is_success (report) && reps[1 ]. strategy isa StrategyDoNothing
22+ printstyled (io, " The task was successfully completed without any actions.\n " ; color= :green )
23+ elseif ! isempty (reps)
24+ actions = unique! ([action_text_not_empty (r. strategy) for r in reps])
25+
26+ println (io, " I tried the following actions:" )
27+ for action in actions
28+ println (io, " - $(action) " )
29+ end
30+ if is_success (report)
31+ printstyled (io, " And the last one worked!\n " ; color= :green )
32+ else
33+ print (io, " But in the end, " )
34+ printstyled (io, " nothing worked :( \n " ; color= :light_red , bold= true )
35+ println (io, " Here is more information:" )
36+ end
37+
38+ println (io)
39+
40+
41+
42+ last_shown_exception = Ref (" asdf" )
43+
44+ for r in reps
45+ e_str = sprint (showerror, r. exception; context= io)
46+ printstyled (io, " -----------\n " ; color= :light_black )
47+ printstyled (io, " I applied the strategy: $(action_text_not_empty (r. strategy)) ...\n " ; bold= true )
48+ # println(io)
49+ if is_success (r)
50+ printstyled (io, " ✔ Task successfully completed.\n " ; color= :light_green )
51+ else
52+ printstyled (io, " ⨯ Task failed. " ; color= :light_red )
53+ printstyled (io, " Captured exception:\n " ; color= :light_yellow )
54+ printstyled (io, e_str == last_shown_exception[] ? " (same as previous)" : e_str)
55+ last_shown_exception[] = e_str
56+ println (io)
57+ end
58+
59+
60+ r. project_changed && printstyled (io, " (The Project.toml was changed.)\n " ; color= :light_black )
61+ r. manifest_changed && printstyled (io, " (The Manifest.toml was changed.)\n " ; color= :light_black )
62+ r. registry_changed && printstyled (io, " (The registry was changed.)\n " ; color= :light_black )
63+ end
64+
65+ end
66+ println (io)
67+
68+ printstyled (io, " === END GRACEFULPKG REPORT ===\n " ; color= :light_black )
69+ end
0 commit comments