Skip to content

Commit c8a9bcd

Browse files
authored
Throw ENSURE exception also with attached debugger (#2094)
When using the nuget package, in debug builds the ensure swallows any error. The "Debug.Fail()" is being optimized away.
1 parent 7bba069 commit c8a9bcd

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

LiteDB/Utils/Constants.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,8 @@ public static void ENSURE(bool conditional, string message = null)
129129
{
130130
Debug.Fail(message);
131131
}
132-
else
133-
{
134-
throw new Exception("LiteDB ENSURE: " + message);
135-
}
132+
133+
throw new Exception("LiteDB ENSURE: " + message);
136134
}
137135
}
138136

@@ -148,10 +146,8 @@ public static void ENSURE(bool ifTest, bool conditional, string message = null)
148146
{
149147
Debug.Fail(message);
150148
}
151-
else
152-
{
153-
throw new Exception("LiteDB ENSURE: " + message);
154-
}
149+
150+
throw new Exception("LiteDB ENSURE: " + message);
155151
}
156152
}
157153

@@ -168,10 +164,8 @@ public static void DEBUG(bool conditional, string message = null)
168164
{
169165
Debug.Fail(message);
170166
}
171-
else
172-
{
173-
throw new Exception("LiteDB DEBUG: " + message);
174-
}
167+
168+
throw new Exception("LiteDB DEBUG: " + message);
175169
}
176170
}
177171
}

0 commit comments

Comments
 (0)