35 ArgumentNullException.ThrowIfNull(error);
37 if (error.Exception ==
null)
40 var errorBuilder = ErrorBuilder.FromError(error)
44 const string ErrorCodeFieldName =
"errorCode";
45 const string AdditionalDataFieldName =
"additionalData";
47 if (error.Exception is DbUpdateException dbUpdateException)
49 if (dbUpdateException.InnerException is OperationCanceledException)
51 logger.LogTrace(dbUpdateException,
"Rethrowing DbUpdateException as OperationCanceledException");
52 throw dbUpdateException.InnerException;
55 logger.LogDebug(dbUpdateException,
"Database conflict!");
57 .SetMessage(dbUpdateException.Message)
58 .SetExtension(ErrorCodeFieldName,
ErrorCode.DatabaseIntegrityConflict)
59 .SetExtension(AdditionalDataFieldName, (dbUpdateException.InnerException ?? dbUpdateException).Message)
66 .SetMessage(error.Exception.Message)
67 .SetExtension(ErrorCodeFieldName,
ErrorCode.InternalServerError)
68 .SetExtension(AdditionalDataFieldName, error.Exception.ToString())
73 .SetMessage(errorMessageException.Message)
74 .SetExtension(ErrorCodeFieldName, errorMessageException.ErrorCode)
75 .SetExtension(AdditionalDataFieldName, errorMessageException.AdditionalData)