| | | 1 | | // ReSharper disable once CheckNamespace |
| | | 2 | | namespace Microsoft.EntityFrameworkCore; |
| | | 3 | | |
| | | 4 | | /// <summary>Errors raised by EF Core itself rather than by SQL Server. Type: <c>DatabaseError</c>.</summary> |
| | | 5 | | public static class EfExceptions |
| | | 6 | | { |
| | | 7 | | private const string DatabaseError = nameof( DatabaseError ); |
| | | 8 | | |
| | | 9 | | |
| | | 10 | | /// <summary>The row changed (or was deleted) since it was read, so the save was rejected.</summary> |
| | | 11 | | /// <param name="exception">The exception, kept for logs.</param> |
| | | 12 | | /// <param name="additionalData">Extra values for logs, e.g. the entity names involved.</param> |
| | | 13 | | /// <returns>The <c>ConcurrencyException</c> error (severity Medium).</returns> |
| | | 14 | | public static Error ConcurrencyException( DbUpdateConcurrencyException exception, IReadOnlyDictionary<string, object |
| | 10 | 15 | | => new( nameof( ConcurrencyException ), DatabaseError, "لم يتم حفظ التغييرات بسبب تعديلات من مستخدم آخر، يرجى تح |
| | 10 | 16 | | "The changes couldn't be saved due to modifications by another user; please refresh and retry", Severity |
| | 10 | 17 | | additionalData ); |
| | | 18 | | |
| | | 19 | | /// <summary>A table couldn't be truncated.</summary> |
| | | 20 | | /// <param name="exception">The exception, kept for logs.</param> |
| | | 21 | | /// <param name="additionalData">Extra values for logs.</param> |
| | | 22 | | /// <returns>The <c>CouldNotTruncate</c> error (severity Medium).</returns> |
| | | 23 | | public static Error CouldNotTruncate( DbUpdateConcurrencyException exception, IReadOnlyDictionary<string, object>? a |
| | 0 | 24 | | => new( nameof( CouldNotTruncate ), DatabaseError, "تعذر تفريغ الجدول.", "The table couldn't be truncated.", Sev |
| | 0 | 25 | | additionalData ); |
| | | 26 | | |
| | | 27 | | /// <summary>The changes couldn't be saved to the database.</summary> |
| | | 28 | | /// <param name="exception">The exception, kept for logs.</param> |
| | | 29 | | /// <param name="additionalData">Extra values for logs.</param> |
| | | 30 | | /// <returns>The <c>UpdateException</c> error (severity Medium).</returns> |
| | | 31 | | public static Error UpdateException( DbUpdateConcurrencyException exception, IReadOnlyDictionary<string, object>? ad |
| | 0 | 32 | | => new( nameof( UpdateException ), DatabaseError, "لم يتم حفظ التغييرات في قاعدة البيانات.", "The changes couldn |
| | 0 | 33 | | Severity.Medium, exception, additionalData ); |
| | | 34 | | |
| | | 35 | | /// <summary>A transaction was started while another one is still open on the same context.</summary> |
| | | 36 | | /// <returns>The <c>TransactionAlreadyStarted</c> error (severity Medium).</returns> |
| | | 37 | | public static Error TransactionAlreadyStarted() |
| | 4 | 38 | | => new( nameof( TransactionAlreadyStarted ), DatabaseError, "توجد معاملة مفتوحة بالفعل.", "A transaction is alre |
| | | 39 | | |
| | | 40 | | /// <summary>Commit or rollback was called with no open transaction.</summary> |
| | | 41 | | /// <returns>The <c>NoActiveTransaction</c> error (severity Medium).</returns> |
| | | 42 | | public static Error NoActiveTransaction() |
| | 8 | 43 | | => new( nameof( NoActiveTransaction ), DatabaseError, "لا توجد معاملة مفتوحة.", "There is no open transaction.", |
| | | 44 | | |
| | | 45 | | /// <summary>Some values didn't meet the rules required for saving.</summary> |
| | | 46 | | /// <param name="exception">The exception, kept for logs.</param> |
| | | 47 | | /// <param name="additionalData">Extra values for logs.</param> |
| | | 48 | | /// <returns>The <c>ValidationException</c> error (severity Medium).</returns> |
| | | 49 | | public static Error ValidationException( DbUpdateConcurrencyException exception, IReadOnlyDictionary<string, object> |
| | 0 | 50 | | => new( nameof( ValidationException ), DatabaseError, "لم يتم حفظ التغييرات لأن بعض البيانات لم تستوفِ الشروط ال |
| | 0 | 51 | | "The changes couldn't be saved because some data didn't meet the required rules.", Severity.Medium, exce |
| | | 52 | | } |