Skip to content

Add notStarted, error(Error), errorWithMetadata, ensure/ensureNotNull Error overloads to result DSL - #44

Merged
mrmans0n merged 3 commits into
mainfrom
feat/error-overloads-ensure
Feb 11, 2026
Merged

mrmans0n merged 3 commits into
mainfrom
feat/error-overloads-ensure

Conversation

@mrmans0n

Copy link
Copy Markdown
Owner

This PR adds Error-specific overloads for ensure and ensureNotNull in the result DSL, allowing callers to provide Error instances directly instead of Throwables.

Changes

  • Added ensure(condition: Boolean, lazyError: () -> Error) overload to ResultScope
  • Added ensureNotNull<T>(value: T?, lazyError: () -> Error): T overload to ResultScope
  • Implemented both methods in ResultScopeImpl to short-circuit with the Error directly
  • Removed duplicate test methods that were left over from PR Add notStarted() to result DSL #42

Benefits

  • More ergonomic API when working with Error instances
  • Preserves metadata and errorId when short-circuiting
  • Maintains backward compatibility with existing Throwable overloads

- Add ensure(condition, () -> Error) overload
- Add ensureNotNull(value, () -> Error) overload
- Remove duplicate test methods from AsyncResultResultDslTest
@mrmans0n mrmans0n changed the title Add Error overloads for ensure/ensureNotNull in result DSL Add notStarted, error(Error), errorWithMetadata, ensure/ensureNotNull Error overloads to result DSL Feb 11, 2026
@github-actions

github-actions Bot commented Feb 11, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-02-11 15:08 UTC

…ata as ext-funs. ensure/ensureNotNull take Error only
@mrmans0n
mrmans0n merged commit 396e4f2 into main Feb 11, 2026
3 checks passed
@mrmans0n
mrmans0n deleted the feat/error-overloads-ensure branch February 11, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant