default HttpResponse recover(Function<? super Throwable, ? extends HttpResponse> function) {
        requireNonNull(function, "function");
        return of(new RecoverableStreamMessage<>(this, function, /* allowResuming */ false));
    }
Recovers a failed {@link HttpResponse} by switching to a returned fallback {@link HttpResponse}
when any error occurs before a {@link ResponseHeaders} is written.
Note that the failed {@link HttpResponse} cannot be recovered from an error if a {@link ResponseHeaders}
was written already.

<p>Example:<pre>{@code
HttpResponse response = HttpResponse.ofFailure(new IllegalStateException("Oops..."));
// The failed HttpResponse will be recovered by the fallback function.
HttpResponse recovered = response.recover(cause -> HttpResponse.of("Fallback"));
assert recovered.aggregate().join().contentUtf8().equals("Fallback");

// As HTTP headers and body were written already before an error occurred,
// the fallback function could not be applied for the failed HttpResponse.
HttpResponseWriter response = HttpResponse.streaming();
response.write(ResponseHeaders.of(HttpStatus.OK));
response.write(HttpData.ofUtf8("Hello"));
response.close(new IllegalStateException("Oops..."));
HttpResponse notRecovered = response.recover(cause -> HttpResponse.of("Fallback"));
// The IllegalStateException will be raised even though a fallback function was added.
notRecovered.aggregate().join();
}</pre>
core/src/main/java/com/linecorp/armeria/common/HttpResponse.java