Stenway Developer Network

catch Keyword

Catching errors

Try-Catch

Handling the error:

try
  doSomething()
catch e
  Console.log(e)
end

Shortened to:

try : doSomething()
catch e : Console.log(e)

Multiple types of errors

try
  arg = doSomethingA()
  doSomethingB(arg)
catch e
  if e is InvalidArgumentError : Console.log("Argument was invalid")
  else : Console.log("Something else went wrong")
end