Skip to content

Commit

Permalink
Merge branch 'ni/remove-permission-denied' into ni/v11-nullability-realm
Browse files Browse the repository at this point in the history
  • Loading branch information
nirinchev committed Mar 24, 2023
2 parents 3d88125 + 901656a commit 794f389
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 182 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -43,6 +43,8 @@
* `RealmValue.AsRealmObject` will now throw an exception if the value contains `null`. If you want to get a nullable string, use `AsNullableRealmObject`. (PR [#3245](https://github.com/realm/realm-dotnet/pull/3245))
* `Realm.SyncSession` will now throw an error if the Realm is not opened with a `PartitionSyncConfiguration` or `FlexibleSyncConfiguration` - before it used to return `null`. (PR [#3245](https://github.com/realm/realm-dotnet/pull/3245))
* `Realm.Subscriptions` will now throw an error if the Realm is not opened with a `FlexibleSyncConfiguration` - before it used to return `null`. (PR [#3245](https://github.com/realm/realm-dotnet/pull/3245))
* Removed `PermissionDeniedException` as it was no longer possible to get it. (Issue [#3272](https://github.com/realm/realm-dotnet/issues/3272))
* Removed some obsolete error codes from the `ErrorCode` enum. All codes removed were obsolete and no longer emitted by the server. (PR [3273](https://github.com/realm/realm-dotnet/issues/3273))

### Enhancements
* Added nullability annotations to the Realm assembly. Now methods returning reference types are correctly annotated to indicate whether the returned value may or may not be null. (Issue [#3248](https://github.com/realm/realm-dotnet/issues/3248))
Expand Down
104 changes: 3 additions & 101 deletions Realm/Realm/Exceptions/Sync/ErrorCode.cs
Expand Up @@ -16,8 +16,6 @@
//
////////////////////////////////////////////////////////////////////////////

using System;

namespace Realms.Sync.Exceptions
{
/// <summary>
Expand All @@ -31,46 +29,16 @@ public enum ErrorCode
/// </summary>
Unknown = -1,

/// <summary>
/// Session has been closed (no error).
/// </summary>
SessionClosed = 200,

/// <summary>
/// Other session level error has occurred.
/// </summary>
OtherSessionError = 201,

/// <summary>
/// Access token has already expired.
/// </summary>
AccessTokenExpired = 202,

/// <summary>
/// Failed to authenticate user.
/// </summary>
BadUserAuthentication = 203,

/// <summary>
/// Path to Realm is invalid.
/// </summary>
IllegalRealmPath = 204,

/// <summary>
/// Path points to non-existing Realm.
/// </summary>
NoSuchRealm = 205,

/// <summary>
/// Permission to Realm has been denied.
/// </summary>
PermissionDenied = 206,

/// <summary>
/// The server file identifier is invalid.
/// </summary>
BadServerFileIdentifier = 207,

/// <summary>
/// The client file identifier is invalid.
/// </summary>
Expand All @@ -96,12 +64,6 @@ public enum ErrorCode
/// </summary>
BadChangeset = 212,

/// <summary>
/// The session has been disabled.
/// </summary>
[Obsolete("This error can no longer happen")]
DisabledSession = 213,

/// <summary>
/// The client file is invalid.
/// </summary>
Expand Down Expand Up @@ -165,69 +127,9 @@ public enum ErrorCode
CompensatingWrite = 231,

/// <summary>
/// Your request parameters did not validate.
/// </summary>
[Obsolete("This error can no longer happen")]
InvalidParameters = 601,

/// <summary>
/// Your request did not validate because of missing parameters.
/// </summary>
[Obsolete("This error can no longer happen")]
MissingParameters = 602,

/// <summary>
/// The provided credentials are invalid.
/// </summary>
[Obsolete("This error can no longer happen")]
InvalidCredentials = 611,

/// <summary>
/// The account does not exist.
/// </summary>
[Obsolete("This error can no longer happen")]
UnknownAccount = 612,

/// <summary>
/// The account cannot be registered as it exists already.
/// </summary>
[Obsolete("This error can no longer happen")]
ExistingAccount = 613,

/// <summary>
/// The path is invalid or current user has no access.
/// </summary>
[Obsolete("This error can no longer happen")]
AccessDenied = 614,

/// <summary>
/// The refresh token is expired.
/// </summary>
[Obsolete("This error can no longer happen")]
ExpiredRefreshToken = 615,

/// <summary>
/// The server is not authoritative for this URL.
/// </summary>
[Obsolete("This error can no longer happen")]
InvalidHost = 616,

/// <summary>
/// The permission offer is expired.
/// </summary>
[Obsolete("This error can no longer happen")]
ExpiredPermissionOffer = 701,

/// <summary>
/// The token used on the permission request does match more than a single permission offer.
/// </summary>
[Obsolete("This error can no longer happen")]
AmbiguousPermissionOfferToken = 702,

/// <summary>
/// The Realm file at the specified path is not available for shared access.
/// An error sent by the server when its data structures used to track client progress
/// become corrupted.
/// </summary>
[Obsolete("This error can no longer happen")]
FileMayNotBeShared = 703,
BadProgress = 233,
}
}
72 changes: 0 additions & 72 deletions Realm/Realm/Exceptions/Sync/PermissionDeniedException.cs

This file was deleted.

10 changes: 1 addition & 9 deletions Realm/Realm/Handles/SessionHandle.cs
Expand Up @@ -18,7 +18,6 @@

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
Expand Down Expand Up @@ -293,14 +292,7 @@ private static void HandleSessionError(IntPtr sessionHandlePtr, SyncError error,
}

SessionException exception;
if (error.error_code == ErrorCode.PermissionDenied)
{
var userInfo = error.user_info_pairs.AsEnumerable().ToDictionary(p => p.Key, p => p.Value);
#pragma warning disable CS0618 // Type or member is obsolete
exception = new PermissionDeniedException(session.User.App, messageString, userInfo);
#pragma warning restore CS0618 // Type or member is obsolete
}
else if (error.error_code == ErrorCode.CompensatingWrite)
if (error.error_code == ErrorCode.CompensatingWrite)
{
var compensatingWrites = error.compensating_writes
.AsEnumerable()
Expand Down

0 comments on commit 794f389

Please sign in to comment.