Example #1
0
        public void HandleCreateTeamCollection(ApiRequest request)
        {
            string repoFolderParentPath = null;

            try
            {
                if (!TeamCollection.PromptForSufficientRegistrationIfNeeded())
                {
                    request.PostSucceeded();
                    return;
                }

                repoFolderParentPath = request.RequiredPostString();

                _tcManager.ConnectToTeamCollection(repoFolderParentPath, _settings.CollectionId);
                _callbackToReopenCollection?.Invoke();

                Analytics.Track("TeamCollectionCreate", new Dictionary <string, string>()
                {
                    { "CollectionId", _settings?.CollectionId },
                    { "CollectionName", _settings?.CollectionName },
                    { "Backend", _tcManager?.CurrentCollection?.GetBackendType() },
                    { "User", CurrentUser }
                });

                request.PostSucceeded();
            }
            catch (Exception e)
            {
                var msgEnglish = "Error creating Team Collection {0}: {1}";
                var msgFmt     = LocalizationManager.GetString("TeamCollection.ErrorCreating", msgEnglish);
                ErrorReport.NotifyUserOfProblem(e, msgFmt, repoFolderParentPath, e.Message);
                Logger.WriteError(String.Format(msgEnglish, repoFolderParentPath, e.Message), e);
                NonFatalProblem.ReportSentryOnly(e, $"Something went wrong for {request.LocalPath()}");

                // Since we have already informed the user above, it is better to just report a success here.
                // Otherwise, they will also get a toast.
                request.PostSucceeded();
            }
        }