How to generically wrap a Rejection with Akka-Http
<p>I would like to use the Akka Http routing system, along with its rejection system but need to nest the response Json for a rejection within a generic Json message block.</p>

<p>I have this working in a very non-generic manner creating a RejectionHandler then adding cases for all possible rejections and handling them all with the specific response code and message.  </p>

<p>example:</p>

<pre><code>    // Wraps string into control block format
def WrappingBlock(msg: String) = ???

val myRejectionHandler = RejectionHandler
.newBuilder()
.handle{case MalformedRequestContentRejection(msg, detail) =&gt;
          complete(BadRequest, WrappingBlock(msg)) }
...     // Further lines for all other possible rejections
...     // along with their response codes and messages.
...     // It would be nice if this was just generic code 
...     // rather than specific to every rejection type.
.result()


val routes = handleRejections(myRejectionHandler){ 
    ...
}
</code></pre>

<p>However, what I would like is the response code that Akka HTTP provides by default and also the pretty print message that is provided, just nested within a Json control wrapper without a line for every possible rejection type.  This seems like it should be possible but I have not been able to complete it.</p>