From 79a9397c4a88fbff9638db0581580cd4a1476ced Mon Sep 17 00:00:00 2001 From: Tobias Grimm Date: Tue, 31 Dec 2024 14:19:52 +0100 Subject: [PATCH] Check SqlState instead of exception message ...when trying to truncate a non-existing table. --- src/Marten/Internal/Storage/DocumentStorage.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Marten/Internal/Storage/DocumentStorage.cs b/src/Marten/Internal/Storage/DocumentStorage.cs index 674bffc48a..10f0e31558 100644 --- a/src/Marten/Internal/Storage/DocumentStorage.cs +++ b/src/Marten/Internal/Storage/DocumentStorage.cs @@ -162,7 +162,7 @@ public void TruncateDocumentStorage(IMartenDatabase database) } catch (PostgresException e) { - if (!e.Message.Contains("does not exist")) + if (e.SqlState != PostgresErrorCodes.UndefinedTable) { throw; } @@ -178,7 +178,7 @@ public async Task TruncateDocumentStorageAsync(IMartenDatabase database, Cancell } catch (PostgresException e) { - if (!e.Message.Contains("does not exist")) + if (e.SqlState != PostgresErrorCodes.UndefinedTable) { throw; }