• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

realm / realm-dotnet / 5716220196

31 Jul 2023 02:52PM UTC coverage: 82.478% (-0.3%) from 82.741%
5716220196

Pull #3261

github

aed2eb
fealebenpae
Merge remote-tracking branch 'origin/main' into yg/updated-marshaling

# Conflicts:
#	Realm/Realm/Handles/SharedRealmHandle.cs
Pull Request #3261: Use modern-er marshaling techniques

2029 of 2601 branches covered (78.01%)

Branch coverage included in aggregate %.

201 of 201 new or added lines in 21 files covered. (100.0%)

6246 of 7432 relevant lines covered (84.04%)

34048.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.95
/Realm/Realm/Exceptions/RealmException.cs
1
////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2016 Realm Inc.
4
//
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
//
17
////////////////////////////////////////////////////////////////////////////
18

19
using System;
20
using Realms.Sync.Exceptions;
21

22
namespace Realms.Exceptions
23
{
24
    /// <summary>
25
    /// Base for Realm specific exceptions.
26
    /// </summary>
27
    public class RealmException : Exception
28
    {
29
        internal RealmException(string detailMessage) : base(detailMessage)
1,482✔
30
        {
31
        }
1,482✔
32

33
        internal RealmException(string detailMessage, Exception innerException) : base(detailMessage, innerException)
×
34
        {
35
        }
×
36

37
        internal static Exception Create(RealmExceptionCodes exceptionCode, string message, RealmExceptionCategories categories)
38
        {
39
            // these are increasing enum value order
40
            switch (exceptionCode)
41
            {
42
                case RealmExceptionCodes.RLM_ERR_DECRYPTION_FAILED:
43
                    return new RealmDecryptionFailedException(message);
×
44

45
                case RealmExceptionCodes.RLM_ERR_FILE_ALREADY_EXISTS:
46
                    return new RealmFileExistsException(message);
×
47

48
                case RealmExceptionCodes.RLM_ERR_FILE_NOT_FOUND:
49
                    return new RealmFileNotFoundException(message);
1✔
50

51
                case RealmExceptionCodes.RLM_ERR_INVALID_DATABASE:
52
                    return new RealmInvalidDatabaseException(message);
9✔
53

54
                case RealmExceptionCodes.RLM_ERR_OUT_OF_MEMORY:
55
                    return new RealmOutOfMemoryException(message);
×
56

57
                case RealmExceptionCodes.RLM_ERR_FILE_PERMISSION_DENIED:
58
                    return new RealmPermissionDeniedException(message);
1✔
59

60
                case RealmExceptionCodes.RLM_ERR_MISMATCHED_CONFIG:
61
                    return new RealmMismatchedConfigException(message);
×
62

63
                case RealmExceptionCodes.RLM_ERR_WRONG_TRANSACTION_STATE:
64
                    return new RealmInvalidTransactionException(message);
11✔
65

66
                case RealmExceptionCodes.RLM_ERR_FILE_FORMAT_UPGRADE_REQUIRED:
67
                case RealmExceptionCodes.RLM_ERR_SCHEMA_MISMATCH:
68
                    return new RealmMigrationNeededException(message);
1✔
69

70
                case RealmExceptionCodes.RowDetached:
71
                    return new RealmInvalidObjectException(message);
5✔
72

73
                case RealmExceptionCodes.RLM_ERR_MISSING_PRIMARY_KEY:
74
                    return new RealmClassLacksPrimaryKeyException(message);
8✔
75

76
                case RealmExceptionCodes.DuplicatePrimaryKey:
77
                    return new RealmDuplicatePrimaryKeyValueException(message);
65✔
78

79
                case RealmExceptionCodes.RealmClosed:
80
                    return new RealmClosedException(message);
×
81

82
                case RealmExceptionCodes.RLM_ERR_SCHEMA_VALIDATION_FAILED:
83
                    return new RealmSchemaValidationException(message);
3✔
84

85
                case RealmExceptionCodes.PropertyTypeMismatch:
86
                    return new RealmException(message);
66✔
87

88
                case RealmExceptionCodes.IndexOutOfRange:
89
                    return new ArgumentOutOfRangeException(message);
833✔
90

91
                case RealmExceptionCodes.ObjectManagedByAnotherRealm:
92
                    return new RealmObjectManagedByAnotherRealmException(message);
4✔
93

94
                case RealmExceptionCodes.KeyAlreadyExists:
95
                case RealmExceptionCodes.DuplicateSubscription:
96
                    return new ArgumentException(message);
226✔
97

98
                case RealmExceptionCodes.InvalidGeospatialShape:
99
                    return new ArgumentException(message);
3✔
100

101
                case RealmExceptionCodes.RLM_ERR_DELETE_OPENED_REALM:
102
                    return new RealmInUseException(message);
538✔
103

104
                case RealmExceptionCodes.RLM_ERR_MIGRATION_FAILED:
105
                    return new RealmMigrationException(message);
1✔
106
            }
107

108
            if (categories.HasFlag(RealmExceptionCategories.RLM_ERR_CAT_APP_ERROR))
43!
109
            {
110
                return new AppException(message, helpLink: null, httpStatusCode: 0);
×
111
            }
112

113
            if (categories.HasFlag(RealmExceptionCategories.RLM_ERR_CAT_FILE_ACCESS))
43!
114
            {
115
                return new RealmFileAccessErrorException(message);
×
116
            }
117

118
            if (categories.HasFlag(RealmExceptionCategories.RLM_ERR_CAT_INVALID_ARG))
43✔
119
            {
120
                return new ArgumentException(message);
29✔
121
            }
122

123
            return new RealmException(message);
14✔
124
        }
125
    }
126
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc