Skip to content

async and swallows errors #23598

Open
Open
@nitely

Description

@nitely

Description

The and function seems to only raise errors for the first async proc.

import std/asyncdispatch

proc ok {.async.} =
  discard

proc err {.async.} =
  raise newException(ValueError, "err")

proc main {.async.} =
  try:
    await ok() and err()
  except ValueError:
    echo "err1"
  try:
    await err() and ok()
  except ValueError:
    echo "err2"
  try:
    await ok() and ok() and err()
  except ValueError:
    echo "err3"

waitFor main()

Nim Version

Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2024-05-11
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: c91b33a
active boot switches: -d:release

Current Output

err2

Expected Output

err1
err2
err3

Possible Solution

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    AsyncEverything related to Nim's async

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions