private void fail(Throwable cause) {
        if (failed) {
            return;
        }
        failed = true;
        state = State.DONE;
        cancel();
        logBuilder.endRequest(cause);
        if (responseWrapper != null) {
            if (responseWrapper.isOpen()) {
                responseWrapper.close(cause);
            } else {
                // To make it sure that the log is complete.
                logBuilder.endResponse(cause);
            }
        } else {
            logBuilder.endResponse(cause);
            originalRes.close(cause);
        }

        final CancellationScheduler scheduler = cancellationScheduler();
        if (scheduler != null) {
            // best-effort attempt to cancel the scheduled timeout task so that RequestContext#cause
            // isn't set unnecessarily
            scheduler.cancelScheduled();
        }
    }
Writes the {@link HttpHeaders trailers} to the {@link Channel}.
Note that the written data is not flushed by this method. The caller should explicitly call
{@link Channel#flush()} when each write unit is done.
core/src/main/java/com/linecorp/armeria/client/AbstractHttpRequestHandler.java