public static ProblemDetails ToProblemDetails(this DbUpdateConcurrencyException exception, HttpStatusCode statusCode, bool includeDetails = false)
 {
     return(new ProblemDetails
     {
         Status = (int)statusCode,
         Title = exception.Message,
         Detail = includeDetails ? exception.ToString() : null,
         Type = nameof(DbUpdateConcurrencyException)
     });
 }
Beispiel #2
0
        private static WebApiErrorResponse HandleDbUpdateConcurrencyError(Exception exception)
        {
            DbUpdateConcurrencyException targetException = exception as DbUpdateConcurrencyException;

            if (targetException == null)
            {
                targetException = exception.InnerException as DbUpdateConcurrencyException;
            }
            if (targetException == null)
            {
                return(null);
            }
            return(new WebApiErrorResponse()
            {
                ErrorType = WebApiErrorTypes.ConflictError,
                Message = Resources.DbUpdateConcurrencyError,
                Description = targetException.ToString()
            });
        }