Qurak

Add messages to functions

Example 4 steps, run in order in one session. Every step was executed against the engine and the output below is what it produced.

Step 1
rsqrt[x_] /; If[TrueQ[x ≥ 0], True, Message[rsqrt::nnarg, x];False]  := Sqrt[x]

No output - this step sets something up for the next one.

Step 2
rsqrt::nnarg = "The argument `1` is not greater than or equal to zero.";

No output - this step sets something up for the next one.

Step 3
rsqrt[2.25]
Output
1.5
Step 4
rsqrt[-2.25]
Output
rsqrt[-2.25]

Functions used

Related recipes

All recipes · Function reference · Use this from an MCP client