From e22ff4589f8cbba7282e0f3b1f23a2d58f25df53 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 4 Oct 2018 07:39:38 +0100 Subject: [PATCH] Update CHANGELOG and README --- CHANGELOG | 2 +- README.org | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1462f1c..aaf77f9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,7 +4,7 @@ CHANGELOG 1.1.0 ----- -* [result] orElseThrow() wraps the error exception in an unchecked MonResultException +* [result] add orElseThrow(Class) and orElseThrowUnchecked() 1.0.0 ----- diff --git a/README.org b/README.org index 0faeaa0..266002d 100644 --- a/README.org +++ b/README.org @@ -821,7 +821,7 @@ **** =T orElseThrow()= Extracts the successful value from the result, or throws the error - as the cause within a the unchecked exception =MonResultException=. + =Throwable=. #+BEGIN_SRC java final Integer result = Result.of(() -> getValue()) @@ -829,6 +829,29 @@ #+END_SRC +**** = T orElseThrow(Class type) throws E= + + Extracts the successful value from the result, or throws the error when it + is of the given type. Any other errors will be thrown inside an + =UnexpectedErrorResultException=. + + #+BEGIN_SRC java + final Integer result = Result.of(() -> getValue()) + .orElseThrow(IOException.class); + #+END_SRC + + +**** =T orElseThrowUnchecked()= + + Extracts the successful value from the result, or throws the error within + an =ErrorResultException=. + + #+BEGIN_SRC java + final Integer result = Result.of(() -> getValue()) + .orElseThrowUnchecked(); + #+END_SRC + + **** =void onError(Consumer errorConsumer)= A handler for error states.