You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you don't explicitly provide a type parameter to fromTryCatch (on either Xor or Validated), the type parameter defaults to Null and it doesn't actually catch exceptions.
scala>Xor.fromTryCatch(thrownewRuntimeException("blargh"))
java.lang.RuntimeException: blargh
at $anonfun$1.apply(<console>:17)
at $anonfun$1.apply(<console>:17)
at cats.data.XorFunctions$FromTryCatchAux.apply(Xor.scala:229)
... 43 elided
scala>Xor.fromTryCatch
res1: cats.data.Xor.FromTryCatchAux[Null] = cats.data.XorFunctions$FromTryCatchAux@1039a2fc
scala>Xor.fromTryCatch[Throwable](thrownewRuntimeException("blargh"))
res2: cats.data.Xor[Throwable,Nothing] =Left(java.lang.RuntimeException: blargh)
I think we should do two things here:
Add a helper to catch NonFatal exceptions, as that is probably generally what people want. This could be called fromTryCatchNonFatal or just catchNonFatal if the former is too verbose.
If you don't explicitly provide a type parameter to
fromTryCatch
(on eitherXor
orValidated
), the type parameter defaults toNull
and it doesn't actually catch exceptions.I think we should do two things here:
NonFatal
exceptions, as that is probably generally what people want. This could be calledfromTryCatchNonFatal
or justcatchNonFatal
if the former is too verbose.fromTryCatch
take implicit evidence that the type parameter is not an unhelpful type such asNothing
(do we need to coverNull
too?). Scalaz does this: https://github.com/scalaz/scalaz/blob/series/7.2.x/core/src/main/scala/scalaz/NotNothing.scalaThe text was updated successfully, but these errors were encountered: