DartRestExceptions should be used to pass messages to DartScalatraServlet.handleOutput, which will produce an appropriate http message.
This exception should be used for failures that do not correspond to any status codes more specific than 500 but still ought to pass some details to the user.
This exception should be used for failures that do not correspond to any status codes more specific than 500 but still ought to pass some details to the user. All other exceptions should simply be passed to DartScalatraServlet without being translated to a DartRestException, which will result in a 500 response and an "Internal Server Error" message.
If you throw this after catching another exception, you can pass that exception as 'cause' and DartScalatraServlet will log it for you.
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.
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()
DartRestExceptions should be used to pass messages to DartScalatraServlet.handleOutput, which will produce an appropriate http message. Using these exceptions will remove the need for complex flow control to handle the multitude of cases that should be handled by a REST action, and will allow you to design your action around successful cases.