In my DataService derrived class I have overriden the HandleException method in order to do custom exception handling (simplified example):
protected override void HandleException(HandleExceptionArgs args)
{
args.Exception = new DataServiceException(
args.ResponseStatusCode,
"RecordAlreadyExist",
"The record with the given ID already exists in the database",
System.Globalization.CultureInfo.CurrentCulture.Name,
null);
base.HandleException(args);
}
This would result into something like the following JSON response:
{
"error": {
"code": "RecordAlreadyExist",
"Message": {
"Language": "en-US",
"Message": "The record with the given ID already exists in the database"
}
}
}
But I would like to have some additional information in the error response like:
{
"error": {
"code": "RecordAlreadyExist",
"Message": {
"Language": "en-US",
"Message": "The record with the given ID already exists in the database"
},
"RecordID": "1234"
}
}
How can I do that? DataServiceException only supports an error code and a message...