Skip to content

Commit

Permalink
Do not try to write duplicate response on error in vibe.web.rest. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Sep 12, 2014
1 parent 54ea846 commit 00caa4d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/vibe/web/rest.d
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,13 @@ private HTTPServerRequestDelegate jsonMethodHandler(T, string method, alias Func
res.writeJsonBody(ret);
}
} catch (HTTPStatusException e) {
res.writeJsonBody([ "statusMessage": e.msg ], e.status);
if (res.headerWritten) logDebug("Response already started when a HTTPStatusException was thrown. Client will not receive the proper error code (%s)!", e.status);
else res.writeJsonBody([ "statusMessage": e.msg ], e.status);
} catch (Exception e) {
// TODO: better error description!
logDebug("REST handler exception: %s", e.toString());
res.writeJsonBody(
if (res.headerWritten) logDebug("Response already started. Client will not receive an error code!");
else res.writeJsonBody(
[ "statusMessage": e.msg, "statusDebugMessage": sanitizeUTF8(cast(ubyte[])e.toString()) ],
HTTPStatus.internalServerError
);
Expand Down

0 comments on commit 00caa4d

Please sign in to comment.