-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from rcardin/9-deprecate-all-the-functions-wit…
…hout-a-scope Deprecated functions without a scope
- Loading branch information
Showing
4 changed files
with
64 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
package in.rcard.raise4s | ||
|
||
import scala.util.control.{ControlThrowable, NoStackTrace, NonFatal} | ||
import scala.util.control.NonFatal | ||
|
||
def fold[A, B, Error]( | ||
private[raise4s] def _fold[Error, B, A]( | ||
block: Raise[Error] ?=> A, | ||
catchBlock: (throwable: Throwable) => B, | ||
recover: (error: Error) => B, | ||
transform: (value: A) => B | ||
): B = | ||
) = { | ||
given raise: Raise[Error] = new DefaultRaise | ||
|
||
try transform(block) | ||
catch | ||
case Raised(error) => recover(error.asInstanceOf[Error]) | ||
case NonFatal(e) => catchBlock(e) | ||
case e: Throwable => throw e | ||
} | ||
|
||
//noinspection NoTailRecursionAnnotation | ||
@deprecated("Use Raise.fold instead", "0.0.3") | ||
def fold[A, B, Error]( | ||
block: Raise[Error] ?=> A, | ||
catchBlock: (throwable: Throwable) => B, | ||
recover: (error: Error) => B, | ||
transform: (value: A) => B | ||
): B = fold(block, ex => throw ex, recover, transform) | ||
): B = | ||
_fold(block, catchBlock, recover, transform) | ||
|
||
//def runRaise[Error, A](block: Raise[Error] ?=> A): Error | A = | ||
// given raise: Raise[Error] = new DefaultRaise | ||
// try block(using raise) | ||
// catch | ||
// case Raised(error) => error.asInstanceOf[Error] | ||
// case throwable: Throwable => throw throwable | ||
@deprecated("Use Raise.fold instead", "0.0.3") | ||
def fold[A, B, Error]( | ||
block: Raise[Error] ?=> A, | ||
recover: (error: Error) => B, | ||
transform: (value: A) => B | ||
): B = _fold(block, ex => throw ex, recover, transform) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters