JanetDocsPlaygroundI'm feeling luckyGitHub sign in

protect



    macro
    boot.janet on line 254, column 1

    (protect & body)

    Evaluate expressions, while capturing any errors. Evaluates to a 
    tuple of two elements. The first element is true if successful, 
    false if an error, and the second is the return value or error.


1 exampleSign in to add an example
Loading...
(protect
  (if (> (math/random) 0.42)
    (error "Good luck")
    "Bad luck"))
# => randomly returns:
# (false "Good luck")
# or
# (true "Bad luck")
pepePlayground