@Test
public void sendError_when_CoapCodeException_whileHandlingRequest() throws Exception {

    server.addRequestHandler("/err", exchange -> {
        throw new CoapCodeException(Code.C503_SERVICE_UNAVAILABLE, new IOException());
    });
    CoapPacket req = newCoapPacket(LOCAL_1_5683).mid(1).con().put().uriPath("/err").build();
    server.coapRequestHandler.handleRequest(req, TransportContext.NULL);
    assertSendResponse(newCoapPacket(LOCAL_1_5683).mid(1).ack(Code.C503_SERVICE_UNAVAILABLE).payload("503 SERVICE UNAVAILABLE"));
}