private static Response toError(Reply reply, long reqId) {
        Message msg = reply.getMessage();
        String err = getErrorMessage(reply);
        Response.Outcome outcome = toOutcome(reply);
        return switch (msg.getType()) {
            case DocumentProtocol.MESSAGE_PUTDOCUMENT ->
                    new DocumentResponse(reqId, ((PutDocumentMessage) msg).getDocumentPut().getDocument(), err, outcome, reply.getTrace());
            case DocumentProtocol.MESSAGE_UPDATEDOCUMENT ->
                    new DocumentUpdateResponse(reqId, ((UpdateDocumentMessage) msg).getDocumentUpdate(), err, outcome, reply.getTrace());
            case DocumentProtocol.MESSAGE_REMOVEDOCUMENT ->
                    new DocumentIdResponse(reqId, ((RemoveDocumentMessage) msg).getDocumentId(), err, outcome, reply.getTrace());
            case DocumentProtocol.MESSAGE_GETDOCUMENT ->
                    new DocumentIdResponse(reqId, ((GetDocumentMessage) msg).getDocumentId(), err, outcome, reply.getTrace());
            default -> new Response(reqId, err, outcome, reply.getTrace());
        };
    }
Returns a concatenated error string from the errors contained in a reply.

@param reply The reply whose errors to concatenate.
@return The error string.
documentapi/src/main/java/com/yahoo/documentapi/messagebus/MessageBusAsyncSession.java