Netflix / Prana

A sidecar for your NetflixOSS based services.
Apache License 2.0
503 stars 98 forks source link

Return real error instead of a generic "Error forwarding request to origin" #24

Open simoami opened 8 years ago

simoami commented 8 years ago

The current error makes it difficult to troubleshoot the issue and "throwable" may contain helpful tips on the reason for the failure:

In the 2 occurrences where ERROR_RESPONSE is being used, here's an improved response:

here

if (Strings.isNullOrEmpty(vip)) {
    serverResponse.getHeaders().set("Content-Type", "application/xml");
    serverResponse.writeString("<status><status_code>500</status_code><message>vip not supplied</message></status>");
    logger.error("VIP not supplied");
    return serverResponse.close();
}

and here

public Observable<Void> call(Throwable throwable) {
    serverResponse.getHeaders().set("Content-Type", "application/xml");
    String msg = "<status><status_code>500</status_code><message>" + throwable.getMessage() + "</message></status>";
    serverResponse.writeString(msg);
    return Observable.just(null);
}
simoami commented 8 years ago

Let me know if I should create a PR.