Skip to content

Commit 0a032ad

Browse files
committed
Better invalid-unit-state messages
1 parent 9701324 commit 0a032ad

File tree

1 file changed

+55
-9
lines changed

1 file changed

+55
-9
lines changed

src/arr/trove/error.arr

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,7 +2508,17 @@ data RuntimeError:
25082508
ED.text(" had the unit: ")],
25092509
ED.code(ED.text(self.r)),
25102510
[ED.para: ED.text("These units are not compatible")]]
2511-
| none => ED.text("TODO")
2511+
| none =>
2512+
[ED.sequence:
2513+
ed-intro(self.op-name + " operation", loc, -1, true),
2514+
ED.cmcode(loc),
2515+
[ED.para:
2516+
ED.text("The left side had the unit: "),
2517+
ED.code(ED.text(self.l))],
2518+
[ED.para:
2519+
ED.text("The right side had the unit: "),
2520+
ED.code(ED.text(self.r))],
2521+
[ED.para: ED.text("These units are not compatible")]]
25122522
end
25132523
else:
25142524
[ED.sequence:
@@ -2542,7 +2552,6 @@ data RuntimeError:
25422552
lam(loc):
25432553
[ED.sequence:
25442554
ed-simple-intro(self.op-name + " operation", loc),
2545-
ED.cmcode(loc),
25462555
[ED.para:
25472556
ED.text("The left side had the unit: "),
25482557
ED.code(ED.text(self.l))],
@@ -2566,15 +2575,52 @@ data RuntimeError:
25662575
end
25672576
| invalid-unit-state(op-name, n, desc) with:
25682577
method render-fancy-reason(self, maybe-stack-loc, src-available, maybe-ast):
2569-
self.render-reason()
2578+
[ED.error:
2579+
cases(O.Option) maybe-stack-loc(0, false):
2580+
| some(loc) =>
2581+
if loc.is-builtin():
2582+
[ED.sequence:
2583+
ed-intro(self.op-name + " function", loc, -1, true),
2584+
[ED.para:
2585+
ED.code(ED.text(tostring(self.n))),
2586+
ED.text(" is an invalid argument because: "),
2587+
ED.text(self.desc)],
2588+
please-report-bug()]
2589+
else if src-available(loc):
2590+
[ED.sequence:
2591+
ed-intro(self.op-name + " function", loc, -1, true),
2592+
ED.cmcode(loc),
2593+
[ED.para:
2594+
ED.code(ED.text(tostring(self.n))),
2595+
ED.text(" is an invalid argument because: "),
2596+
ED.text(self.desc)]]
2597+
end
2598+
| none =>
2599+
[ED.sequence:
2600+
[ED.para:
2601+
ED.text("The " + self.op-name + " function failed.")],
2602+
[ED.para:
2603+
ED.code(ED.text(tostring(self.n))),
2604+
ED.text(" is an invalid argument because: "),
2605+
ED.text(self.desc)]]
2606+
end]
25702607
end,
25712608
method render-reason(self):
2572-
[ED.error:
2573-
[ED.para:
2574-
ED.text("The " + self.op-name + " operation failed. "),
2575-
ED.text(tostring(self.n)),
2576-
ED.text(" is an invalid argument because: "),
2577-
ED.text(self.desc)]]
2609+
[ED.error: ED.maybe-stack-loc(0, false,
2610+
lam(loc):
2611+
[ED.sequence:
2612+
ed-simple-intro(self.op-name + " function", loc),
2613+
[ED.para:
2614+
ED.code(ED.text(tostring(self.n))),
2615+
ED.text(" is an invalid argument because: "),
2616+
ED.text(self.desc)]]
2617+
end,
2618+
[ED.sequence:
2619+
[ED.para: ED.text("The " + self.op-name + " function failed.")],
2620+
[ED.para:
2621+
ED.code(ED.text(tostring(self.n))),
2622+
ED.text(" is an invalid argument because: "),
2623+
ED.text(self.desc)]])]
25782624
end
25792625
end
25802626

0 commit comments

Comments
 (0)