Skip to content

Commit 53a2b1f

Browse files
authored
CSHARP-4082: Include full stack trace when LINQ3 MongoQuery.ToString() encounters an unexpected exception. (#737)
1 parent 8fc0764 commit 53a2b1f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/MongoDB.Driver/Linq/Linq3Implementation/MongoQuery.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
using System.Linq.Expressions;
2121
using System.Threading;
2222
using System.Threading.Tasks;
23-
using MongoDB.Bson;
24-
using MongoDB.Driver.Linq;
2523
using MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToExecutableQueryTranslators;
2624

2725
namespace MongoDB.Driver.Linq.Linq3Implementation
@@ -108,10 +106,14 @@ public override string ToString()
108106
var executableQuery = ExpressionToExecutableQueryTranslator.Translate<TDocument, TOutput>(_provider, _expression);
109107
return executableQuery.ToString();
110108
}
111-
catch (Exception ex)
109+
catch (ExpressionNotSupportedException ex)
112110
{
113111
return ex.Message;
114112
}
113+
catch (Exception ex)
114+
{
115+
return ex.ToString();
116+
}
115117
}
116118
}
117119
}

0 commit comments

Comments
 (0)