daml/compiler/damlc/tests/daml-test-files/ExceptionSyntax.daml
Sofia Faro f670daec6f
Add try-catch syntax. (#9203)
* Add try-catch syntax.

changelog_begin
changelog_end

* ++

* +++

* ++[>++<-]>

* ++[>++<-]>+

* ++[>+++<-]>

* ++[>+++<-]>+

* ++[>++++<-]>

* Use try-catch in ExceptionSyntax test

* add a syntax test for try catch

* +++[>+++<-]>

* +++[>+++<-]>+

* enable test4

* typo

* add a test with multiple patterns and guards

* final patch sha

* update stack snapshot (unix)

* update stack snapshot (win)
2021-03-25 13:36:09 +00:00

29 lines
706 B
Haskell

-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
-- @SINCE-LF 1.dev
-- @QUERY-LF [ .modules[].exceptions[] ] | length == 1
-- | Test that exception syntax is correctly handled.
-- This is the "sugared" counterpart to ExceptionDesugared.
module ExceptionSyntax where
import DA.Exception (throw)
import DA.Assert ((===))
exception MyException
with
m : Text
where
message m
tryCatchExample = scenario do
p <- getParty "Alice"
x <- submit p do
try do
throw (MyException "ok")
pure "err"
catch
MyException m -> pure m
x === "ok"