Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print warning when calling failed #521

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions chronos/internal/raisesfutures.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import
std/[macros, sequtils],
../futures

{.push raises: [].}

type
InternalRaisesFuture*[T, E] = ref object of Future[T]
## Future with a tuple of possible exception types
Expand Down Expand Up @@ -205,13 +207,20 @@ macro checkRaises*[T: CatchableError](
`warning`
assert(`runtimeChecker`, `errorMsg`)

proc error*[T](future: InternalRaisesFuture[T, void]): ref CatchableError {.
func failed*[T](future: InternalRaisesFuture[T, void]): bool {.inline.} =
## Determines whether ``future`` finished with an error.
static:
warning("No exceptions possible with this operation, `failed` always returns false")

false

func error*[T](future: InternalRaisesFuture[T, void]): ref CatchableError {.
raises: [].} =
static:
warning("No exceptions possible with this operation, `error` always returns nil")
nil

proc readError*[T](future: InternalRaisesFuture[T, void]): ref CatchableError {.
func readError*[T](future: InternalRaisesFuture[T, void]): ref CatchableError {.
raises: [ValueError].} =
static:
warning("No exceptions possible with this operation, `readError` always raises")
Expand Down
Loading