Skip to main content

Error

Symmetry of error throwing and handling.

Try-catch#

Symbol: |->
Translated to JavaScript try-catch.

First parameter is catch function.
Other parameters are try lines.
Unlike JavaScript try-catch operator |-> in Una always returns some value and it doesn't have finally block.

Example:

|->
<-
= getName null
getName ()
-> error
console.log error
'John'

If you need to run async code use <-- instead of <- in try or --> instead -> in catch:

|->
<--
getNameAsync ()
--> error
console.log error
"John"

Throw error#

Symbol: <-|
Translated to JavaScript throw.

Example:

= addOneToNumber -> number
?! (isNaN number)
<-| "number is not valid"
+ number 1