protected void ValidateThatServerIsUpAndFileSystemExists(RavenFileSystemClient fsClient) { var shouldDispose = false; try { var fileSystemStats = fsClient.StatsAsync().Result; } catch (Exception e) { shouldDispose = true; var responseException = e as ErrorResponseException; if (responseException != null && responseException.StatusCode == HttpStatusCode.ServiceUnavailable && responseException.Message.StartsWith("Could not find a file system named:")) { throw new InvalidOperationException( string.Format( "Migration tool does not support file system creation (file system '{0}' on server '{1}' must exist before running this tool).", fsClient.FileSystemName, fsClient.ServerUrl), e); } if (e.InnerException != null) { var webException = e.InnerException as WebException; if (webException != null) { throw new InvalidOperationException(string.Format("Migration tool encountered a connection problem: '{0}'.", webException.Message), webException); } } throw new InvalidOperationException(string.Format("Migration tool encountered a connection problem: '{0}'.", e.Message), e); } finally { if (shouldDispose) { fsClient.Dispose(); } } }
protected void ValidateThatServerIsUpAndFileSystemExists(RavenFileSystemClient fsClient) { var shouldDispose = false; try { var fileSystemStats = fsClient.StatsAsync().Result; } catch (Exception e) { shouldDispose = true; var responseException = e as ErrorResponseException; if (responseException != null && responseException.StatusCode == HttpStatusCode.ServiceUnavailable && responseException.Message.StartsWith("Could not find a file system named:")) throw new InvalidOperationException( string.Format( "Migration tool does not support file system creation (file system '{0}' on server '{1}' must exist before running this tool).", fsClient.FileSystemName, fsClient.ServerUrl), e); if (e.InnerException != null) { var webException = e.InnerException as WebException; if (webException != null) { throw new InvalidOperationException(string.Format("Migration tool encountered a connection problem: '{0}'.", webException.Message), webException); } } throw new InvalidOperationException(string.Format("Migration tool encountered a connection problem: '{0}'.", e.Message), e); } finally { if (shouldDispose) fsClient.Dispose(); } }