Skip to content

Commit

Permalink
Merge pull request #839 from Geod24/enforce-returns
Browse files Browse the repository at this point in the history
Bring vibe.d's enforce closer to std.exception.enforce
  • Loading branch information
s-ludwig committed Sep 24, 2014
2 parents fc00b8b + 6b0ff2d commit 82ce674
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/vibe/http/common.d
Expand Up @@ -102,17 +102,17 @@ unittest
/**
Utility function that throws a HTTPStatusException if the _condition is not met.
*/
void enforceHTTP(T)(T condition, HTTPStatus statusCode, string message = null)
T enforceHTTP(T)(T condition, HTTPStatus statusCode, lazy string message = null)
{
enforce(condition, new HTTPStatusException(statusCode, message));
return enforce(condition, new HTTPStatusException(statusCode, message));
}

/**
Utility function that throws a HTTPStatusException with status code "400 Bad Request" if the _condition is not met.
*/
void enforceBadRequest(T)(T condition, string message = null)
T enforceBadRequest(T)(T condition, lazy string message = null)
{
enforceHTTP(condition, HTTPStatus.badRequest, message);
return enforceHTTP(condition, HTTPStatus.badRequest, message);
}


Expand Down

0 comments on commit 82ce674

Please sign in to comment.