Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/Result/Err.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public function expect(string|Throwable $message): mixed
throw $message;
}

if ($this->err instanceof Throwable) {
throw new RuntimeException($message, previous: $this->err);
}

throw new RuntimeException($message);
}

Expand Down
6 changes: 5 additions & 1 deletion src/Result/Ok.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ public function expect(string|Throwable $message): mixed

public function expectErr(Throwable|string $message): mixed
{
throw $message instanceof Throwable ? $message : new RuntimeException($message);
if ($message instanceof Throwable) {
throw $message;
}

throw new RuntimeException($message);
}

public function inspect(callable $f): Result
Expand Down