ErrorState *err;
if (errorReply) {
- err = new ErrorState(request.getRaw(), errorReply);
+ err = new ErrorState(request.getRaw(), errorReply, al);
} else {
// with no reply suitable for relaying, answer with 502 (Bad Gateway)
err = new ErrorState(ERR_CONNECT_FAIL, Http::scBadGateway, request.getRaw(), al);
return new ErrorState(type, status, request.getRaw(), ale);
}
-ErrorState::ErrorState(err_type t) :
+ErrorState::ErrorState(const err_type t, const AccessLogEntry::Pointer &anAle):
type(t),
page_id(t),
- callback(nullptr)
+ callback(nullptr),
+ ale(anAle)
{
}
ErrorState::ErrorState(err_type t, Http::StatusCode status, HttpRequest * req, const AccessLogEntry::Pointer &anAle) :
- ErrorState(t)
+ ErrorState(t, anAle)
{
if (page_id >= ERR_MAX && ErrorDynamicPages[page_id - ERR_MAX]->page_redirect != Http::scNone)
httpStatus = ErrorDynamicPages[page_id - ERR_MAX]->page_redirect;
request = req;
src_addr = req->client_addr;
}
-
- ale = anAle;
}
-ErrorState::ErrorState(HttpRequest * req, HttpReply *errorReply) :
- ErrorState(ERR_RELAY_REMOTE)
+ErrorState::ErrorState(HttpRequest * req, HttpReply *errorReply, const AccessLogEntry::Pointer &anAle):
+ ErrorState(ERR_RELAY_REMOTE, anAle)
{
Must(errorReply);
response_ = errorReply;
HttpReply *
ErrorState::BuildHttpReply()
{
+ // Make sure error codes get back to the client side for logging and
+ // error tracking.
+ if (request) {
+ request->error.update(type, detail);
+ request->error.update(SysErrorDetail::NewIfAny(xerrno));
+ } else if (ale) {
+ Error err(type, detail);
+ err.update(SysErrorDetail::NewIfAny(xerrno));
+ ale->updateError(err);
+ }
+
if (response_)
return response_.getRaw();
rep->body.set(body);
}
- // Make sure error codes get back to the client side for logging and
- // error tracking.
- if (request) {
- request->error.update(type, detail);
- request->error.update(SysErrorDetail::NewIfAny(xerrno));
- } else if (ale) {
- Error err(type, detail);
- err.update(SysErrorDetail::NewIfAny(xerrno));
- ale->updateError(err);
- }
-
return rep;
}
ErrorState() = delete; // not implemented.
/// creates an ERR_RELAY_REMOTE error
- ErrorState(HttpRequest * request, HttpReply *);
+ ErrorState(HttpRequest * request, HttpReply *, const AccessLogEntryPointer &);
~ErrorState();
typedef ErrorPage::Build Build;
/// initializations shared by public constructors
- explicit ErrorState(err_type type);
+ ErrorState(err_type, const AccessLogEntryPointer &);
/// locates the right error page template for this error and compiles it
SBuf buildBody();