From c5eef0418df2ae6a97c54839fa010ff60d96f78b Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 8 Jan 2022 16:14:51 -0500 Subject: =?UTF-8?q?Add=20error=20messages=20to=20generated=20markdown=20do?= =?UTF-8?q?cs=20with=20=E2=80=A2CurrentError=20(fixes=20#22)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/doc/assert.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docs/doc/assert.html') diff --git a/docs/doc/assert.html b/docs/doc/assert.html index 2e112283..1d56a9ed 100644 --- a/docs/doc/assert.html +++ b/docs/doc/assert.html @@ -9,19 +9,19 @@ ↗️
    ! 2=2  # Passed
 1
     ! 2=3  # Failed
-ERROR
+Error: Assertion error
 

To pass, the right argument must be exactly the number 1; any other value causes an error. For example, an array of 1s still causes an error; use ´ to convert a boolean array to a single boolean that indicates whether all of its values are true.

↗️
    ! (∧=∨¬)⌜˜ 2
-ERROR
+Error: 2‿2⥊1‿1‿1‿1
     ! ´ (∧=∨¬)⌜˜ 2
 1
 

Assert can take a left argument, which gives a message to be associated with the error. It's typical to use a string for the left argument in order to display it to the programmer, but the left argument can be any value.

↗️
    "Message" ! 0
-ERROR
+Error: Message
     ,"abc",˜ ! '0'  # Okay this is not a very helpful printout
-ERROR
+Error: ⟨∘,"abc",˜⟩
 

Computing the error message on demand

Because the left argument to a function is always computed before the function is called, Assert doesn't let you compute the error message only if there's an error. This might be a problem if the error message computation is slow or has side effects. There are a few ways to work around the issue:

-- cgit v1.2.3