SetFingerprint prevents logging in Sentry

Dear all, I added SetFingerprint in C# .Net Core as explained in document:

                        SentrySdk.Init(options =>
                            options.BeforeSend = _event =>
                                if (_event .Exception is Microsoft.Data.SqlClient.SqlException ||
                                    _event .Exception is MembershipDeleteException)
                                    _event .SetFingerprint(new[] { "database error" });
                                    _event .SetFingerprint(new[] { "unknown error" });
                                return _event ;

now there is no event in the Sentry. If I comment these lines then it works

I found out it is not working because @event.Exception is null. Now, trying to find out how to set it

it could be null if somewhere is capturing messages, for example:

SentrySdk.CaptureMessage(“Hello World”);
SentrySdk.CaptureMessage(exception.Message, SentryLevel.Error);

That triggers the BeforeSend callback and has no exception.

Also, are you capturing exceptions and they don’t have any data on @event.Exception? If so, would you mind sharing how are you capturing the exception?