# Issue with exceptions

**URL:** <https://forum.canton.network/t/issue-with-exceptions/2812>\
**Category:** App Development\
**Tags:** features and bugs\
**Created:** [July 7, 2021, 9:16am UTC](https://forum.canton.network/t/issue-with-exceptions/2812 "2021-07-07T09:16:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krisztian\_Pinter](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/krisztian_pinter/32/2188_2.png) [@Krisztian\_Pinter](https://forum.canton.network/u/Krisztian_Pinter)\
**Post date:** [July 7, 2021, 9:16am UTC](https://forum.canton.network/t/issue-with-exceptions/2812/1 "2021-07-07T09:16:55Z")

</div>

Hey,

I’m trying to experiment with exceptions but I get a weird error. (Daml SDK 1.14.0)

I took [a test](https://github.com/digital-asset/daml/blob/fd62671e0ba6790561c7a2ba0bf168dc5dda962e/compiler/damlc/tests/daml-test-files/ExceptionTryCatch.daml#L9-L16) from the Daml repo:

```haskell
module Main where

import DA.Exception

test1 : ActionCatch m => m Int
test1 =
    try
        pure (10 / 0)
    catch
        (_: ArithmeticError) -> pure 0

```

I get the following error when compiling:

```haskell
 $ daml build
Compiling daml-new to a DAR.
File: daml/Main.daml
Hidden: no
Range: 5:9-5:20
Source: typecheck
Severity: DsError
Message: daml/Main.daml:5:9: error:Not in scope: type constructor or class ‘ActionCatch’
File: daml/Main.daml
Hidden: no
Range: 7:5-10:39
Source: typecheck
Severity: DsError
Message: 
  daml/Main.daml:7:5: error:
  Not in scope: ‘DA.Internal.Desugar._tryCatch’
  Perhaps you meant one of these:
  ‘DA.Internal.Desugar.create’ (imported from DA.Internal.Desugar),
  ‘DA.Internal.Desugar.fetch’ (imported from DA.Internal.Desugar),
  ‘DA.Internal.Desugar.concat’ (imported from DA.Internal.Desugar)
  Module ‘DA.Internal.Desugar’ does not export ‘_tryCatch’.
File: daml/Main.daml
Hidden: no
Range: 10:9-10:39
Source: typecheck
Severity: DsError
Message: 
  daml/Main.daml:10:9: error:
  Not in scope: ‘DA.Internal.Desugar.fromAnyException’
  Perhaps you meant one of these:
  ‘DA.Internal.Desugar.fromAnyChoice’ (imported from DA.Internal.Desugar),
  ‘DA.Internal.Desugar.fromAnyTemplate’ (imported from DA.Internal.Desugar),
  ‘DA.Internal.Desugar._fromAnyChoice’ (imported from DA.Internal.Desugar)
  Module ‘DA.Internal.Desugar’ does not export ‘fromAnyException’.
File: daml/Main.daml
Hidden: no
Range: 10:13-10:28
Source: typecheck
Severity: DsError
Message: daml/Main.daml:10:13: error:Not in scope: type constructor or class ‘ArithmeticError’
ERROR: Creation of DAR file failed.

```

Since this is a working test, I assume something is wrong with my setup. However other features work in Daml, only the use of exceptions triggers this.

Any suggestions? Thank you!

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [July 7, 2021, 9:25am UTC](https://forum.canton.network/t/issue-with-exceptions/2812/2 "2021-07-07T09:25:49Z")

</div>

> [@Krisztian\_Pinter](#):
>
> ```haskell
> test1 : ActionCatch m => m Int
> test1 =
> try
> pure (10 / 0)
> catch
> (_: ArithmeticError) -> pure 0
> 
> ```

I can reproduce this by running `daml new t` and then adding your code snippet.

While the error message could be improved, this is essentially expected behaviour: exceptions are not supported until Daml LF 1.14, which is not the default compiler output version in current stable Daml releases. To force the compiler to emit Daml LF 1.14, you can add

```yaml
build-options:
  - --target=1.14

```

to your `daml.yml` file.

With that addition, this code snippet works for me. Can you confirm this fixes it for you too?

---

<div class="post-metadata">

**Author:** ![Krisztian\_Pinter](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/krisztian_pinter/32/2188_2.png) [@Krisztian\_Pinter](https://forum.canton.network/u/Krisztian_Pinter)\
**Post date:** [July 7, 2021, 1:03pm UTC](https://forum.canton.network/t/issue-with-exceptions/2812/3 "2021-07-07T13:03:12Z")

</div>

Yep, that indeed fixed it, thank you!
