mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 17:28:46 +03:00
f670daec6f
* 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)
29 lines
706 B
Haskell
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"
|