vmeretail / subscriptionservice

Lightweight and easy to use library, which allows you to manage you delivering events from persistent subscriptions.
12 stars 0 forks source link

CreatePersistentSubscriptionAsync only checks inner exception #139

Open StevenBlair123 opened 4 years ago

StevenBlair123 commented 4 years ago

Describe the bug When an Exception occurs when starting a projection (becasue it doesnt exist) our code does the following:


 if (e.InnerException != null && e.InnerException.Message == "Subscription not found")
  {
                    //Create the Group
                    await this.EventStoreConnection.CreatePersistentSubscriptionAsync(persistentSubscriptionBuilder.StreamName,
                                                                                      persistentSubscriptionBuilder.GroupName,
                                                                                      persistentSubscriptionBuilder.PersistentSubscriptionSettings,
                                                                                      persistentSubscriptionBuilder.UserCredentials);

                    await ConnectToPersistentSubscriptionAsync();
                }
                else
                {
                    throw;
                }

The InnerException is null so it never detects the "Subscription not found" message.

We should check the parent exception as well.

To Reproduce Create a new projection and attempt to create from a console application (i thinkt this is the important part)

Expected behavior The code should detect the message that the persistent subscription does not exist, and attempt to create it