Skip to content

Commit 4e4a4ba

Browse files
author
Chris Santero
committed
add convenience method for 400 errors
1 parent f372dcf commit 4e4a4ba

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

JSONAPI/Documents/Builders/JsonApiException.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@ public static JsonApiException Create(string title, string detail, HttpStatusCod
5555
return new JsonApiException(error);
5656
}
5757

58+
/// <summary>
59+
/// Creates a JsonApiException to send a 400 Bad Request error.
60+
/// </summary>
61+
public static JsonApiException CreateForBadRequest(string detail = null)
62+
{
63+
var error = new Error
64+
{
65+
Id = Guid.NewGuid().ToString(),
66+
Status = HttpStatusCode.BadRequest,
67+
Title = "Bad request",
68+
Detail = detail
69+
};
70+
return new JsonApiException(error);
71+
}
72+
5873
/// <summary>
5974
/// Creates a JsonApiException to send a 404 Not Found error.
6075
/// </summary>

0 commit comments

Comments
 (0)