Files
calc/help/newerror
2017-05-21 15:38:25 -07:00

40 lines
837 B
Plaintext

NAME
newerror - create a new error type
SYNOPSIS
newerror([str])
TYPES
str non-null string
return error-value
DESCRIPTION
With or without an argument, newerror() creates an error-value
different from already existing error-values. With the argument
str, if x == newerror(str), strerror(iserror(x)) returns str.
EXAMPLE
> e1 = newerror("Non-positive side")
> e2 = newerror("Non-triangle sides")
> define area(a,b,c) {\
> local s;\
> if (!(a > 0) || !(b > 0) || !(c > 0)) return e1;\
> s = (a + b + c)/2;\
> if (s <= a || s <= b || s <= c) return e2;\
> return sqrt(s * (s - a) * (s - b) * (s - c)); }
> print strerror(iserror(area(8,2,5)))
Non-triangle sides
LIMITS
none - XXX - is this correct?
LIBRARY
none
SEE ALSO
errorcodes, iserror, error