示例#1
0
        /// <inheritdoc />
        public async Task <MigrationResult> MigrateSafeAsync()
        {
            try
            {
                await MigrateAsync();

                return(MigrationResult.SuccessfullyResult());
            }
            catch (MigrationException e)
            {
                return(MigrationResult.FailureResult(e.Error, e.Message));
            }
            catch (Exception e)
            {
                return(MigrationResult.FailureResult(MigrationError.Unknown, e.Message));
            }
        }
        /// <inheritdoc />
        public async Task <MigrationResult> MigrateSafeAsync(CancellationToken token = default)
        {
            try
            {
                await MigrateAsync(token);

                return(MigrationResult.SuccessfullyResult());
            }
            catch (MigrationException e)
            {
                _logger?.LogError(e, e.Message);
                return(MigrationResult.FailureResult(e.Error, e.Message));
            }
            catch (Exception e)
            {
                _logger?.LogError(e, $"Error while migrating database {_dbProvider.DbName}. Reason: {e.Message}");
                return(MigrationResult.FailureResult(MigrationError.Unknown, e.Message));
            }
        }