Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 0192b3b

Browse files
committed
Call OrmLiteConfig.ExceptionFilter in all managed Exec commands
1 parent 180ee75 commit 0192b3b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/ServiceStack.OrmLite/OrmLiteExecFilter.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,15 @@ public virtual Task<T> Exec<T>(IDbConnection dbConn, Func<IDbCommand, Task<T>> f
113113
return filter(dbCmd)
114114
.ContinueWith(t =>
115115
{
116-
DisposeCommand(dbCmd, dbConn);
117-
118116
if (t.IsFaulted)
119-
throw t.Exception.UnwrapIfSingleException();
117+
{
118+
var ex = t.Exception.UnwrapIfSingleException();
119+
OrmLiteConfig.ExceptionFilter?.Invoke(dbCmd, ex);
120+
DisposeCommand(dbCmd, dbConn);
121+
throw ex;
122+
}
120123

124+
DisposeCommand(dbCmd, dbConn);
121125
return t.Result;
122126
});
123127
}
@@ -142,6 +146,14 @@ public virtual Task Exec(IDbConnection dbConn, Func<IDbCommand, Task> filter)
142146
return filter(dbCmd)
143147
.Then(t =>
144148
{
149+
if (t.IsFaulted)
150+
{
151+
var ex = t.Exception.UnwrapIfSingleException();
152+
OrmLiteConfig.ExceptionFilter?.Invoke(dbCmd, ex);
153+
DisposeCommand(dbCmd, dbConn);
154+
throw ex;
155+
}
156+
145157
DisposeCommand(dbCmd, dbConn);
146158
return t;
147159
});

0 commit comments

Comments
 (0)