A set of implicit conversions providing methods for exceptions and exception-handling classes
(e.g., Future, Try, CompletableFuture) that allow performing side-effects (i.e., logging) on
the exceptions and exception message. Each method returns the object they are called on, so
they are useful for logging without interrupting method chaining.
1) val future = dbClient.queryReturningFuture( query ).logged
2) val completableFuture = javaClient.queryReturningCompletableFuture( query ).logged
3) val try = dbClient.queryReturningTry( query ).logged
4) val result : Option[ Int ] = queryResponse match {
case Success( value ) => Some( value )
case Failure( e ) =>
e.log
}
Log level is error, to change log level use .loggedInfo, .loggedWarning, or .loggedDebug
Stack traces can be logged with your own logger using .withErrorString( LOG.info ), and
custom error handling can be achieved using .withError() instead of .withErrorString()
A set of implicit conversions providing methods for exceptions and exception-handling classes (e.g., Future, Try, CompletableFuture) that allow performing side-effects (i.e., logging) on the exceptions and exception message. Each method returns the object they are called on, so they are useful for logging without interrupting method chaining.
Basic usages:
import com.twosixlabs.dart.exceptions.ExceptionImplicits._
1) val future = dbClient.queryReturningFuture( query ).logged 2) val completableFuture = javaClient.queryReturningCompletableFuture( query ).logged 3) val try = dbClient.queryReturningTry( query ).logged 4) val result : Option[ Int ] = queryResponse match { case Success( value ) => Some( value ) case Failure( e ) => e.log }
Log level is error, to change log level use .loggedInfo, .loggedWarning, or .loggedDebug Stack traces can be logged with your own logger using .withErrorString( LOG.info ), and custom error handling can be achieved using .withError() instead of .withErrorString()